alguns atributos sao especificos de Unix.

This commit is contained in:
tuler
2004-11-10 14:09:45 +00:00
parent c9286d40fe
commit 688efd472c

View File

@@ -1,192 +1,192 @@
<! See Copyright Notice in license.html> <! See Copyright Notice in license.html>
<html> <html>
<head> <head>
<title>LuaFileSystem</title> <title>LuaFileSystem</title>
<style type="text/css"> <style type="text/css">
ul { list-style-type: disc }; ul { list-style-type: disc };
</style> </style>
</head> </head>
<body bgcolor="#FFFFFF"> <body bgcolor="#FFFFFF">
<hr> <hr>
<center> <center>
<table border=0 cellspacing=2 cellpadding=2> <table border=0 cellspacing=2 cellpadding=2>
<tr><td align=center><a href="http://www.keplerproject.org/luafilesystem"> <tr><td align=center><a href="http://www.keplerproject.org/luafilesystem">
<img border=0 alt="LuaFileSystem logo" src="luafilesystem.png"></a> <img border=0 alt="LuaFileSystem logo" src="luafilesystem.png"></a>
<tr><td align=center><big><b>LuaFileSystem Reference Manual</b></big> <tr><td align=center><big><b>LuaFileSystem Reference Manual</b></big>
<tr><td align=center valign=top>File system library for the <tr><td align=center valign=top>File system library for the
<a href="http://www.lua.org">Lua</a> <a href="http://www.lua.org">Lua</a>
programming language programming language
</table> </table>
</center> </center>
<p> <p>
<center><small> <center><small>
<a href="index.html">home</a> &middot; <a href="index.html">home</a> &middot;
<a href="#introduction">introduction</a> &middot; <a href="#introduction">introduction</a> &middot;
<a href="#reference">reference</a> &middot; <a href="#reference">reference</a> &middot;
<a href="#example">example</a> <a href="#example">example</a>
</small></center> </small></center>
<p> <p>
<hr> <hr>
<a name="introduction"></a> <a name="introduction"></a>
<h2>Introduction</h2> <h2>Introduction</h2>
<p> <p>
LuaFileSystem is a <a href="http://www.lua.org">Lua</a> library LuaFileSystem is a <a href="http://www.lua.org">Lua</a> library
developed to complement the set of functions related to file systems offered developed to complement the set of functions related to file systems offered
by the standard Lua distribution. by the standard Lua distribution.
<p> <p>
LuaFileSystem is free software and uses the same LuaFileSystem is free software and uses the same
<a href="license.html">license</a> <a href="license.html">license</a>
as Lua 5.0. as Lua 5.0.
</p> </p>
<a name="reference"></a> <a name="reference"></a>
<h2>Reference</h2> <h2>Reference</h2>
<p> <p>
LuaFileSystem offers the following functions: LuaFileSystem offers the following functions:
<ul> <ul>
<a name="attributes"></a> <a name="attributes"></a>
<li> <b><tt>lfs.attributes (filepath)</tt></b> <br> <li> <b><tt>lfs.attributes (filepath)</tt></b> <br>
Obtains the file attributes. Obtains the file attributes.
The attributes are: The attributes are:
<ul> <ul>
<i>dev</i>, device inode resides on;<br> <i>dev</i>, device inode resides on;<br>
<i>ino</i>, inode's number;<br> <i>ino</i>, inode's number;<br>
<i>mode</i>, inode protection mode (<small>values could be <i>mode</i>, inode protection mode (<small>values could be
<tt>file</tt>, <tt>directory</tt>, <tt>link</tt>, <tt>socket</tt>, <tt>named pipe</tt>, <tt>char device</tt>, <tt>block device</tt> or <tt>other</tt></small>);<br> <tt>file</tt>, <tt>directory</tt>, <tt>link</tt>, <tt>socket</tt>, <tt>named pipe</tt>, <tt>char device</tt>, <tt>block device</tt> or <tt>other</tt></small>);<br>
<i>nlink</i>, number of hard links to the file;<br> <i>nlink</i>, number of hard links to the file;<br>
<i>uid</i>, user-id of owner;<br> <i>uid</i>, user-id of owner;<br>
<i>gid</i>, group-id of owner;<br> <i>gid</i>, group-id of owner;<br>
<i>rdev</i>, device type, for special file inode;<br> <i>rdev</i>, device type, for special file inode;<br>
<i>access</i>, time of last access;<br> <i>access</i>, time of last access;<br>
<i>modification</i>, time of last data modification;<br> <i>modification</i>, time of last data modification;<br>
<i>change</i>, time of last file status change;<br> <i>change</i>, time of last file status change;<br>
<i>size</i>, file size, in bytes;<br> <i>size</i>, file size, in bytes;<br>
<i>blocks</i>, block allocated for file;<br> <i>blocks</i>, block allocated for file; (Unix only)<br>
<i>blksize</i>, optimal file system I/O blocksize;<br> <i>blksize</i>, optimal file system I/O blocksize; (Unix only)<br>
</ul> </ul>
Returns a table with file attributes described above. Returns a table with file attributes described above.
<a name="chdir"></a> <a name="chdir"></a>
<li> <b><tt>lfs.chdir (path)</tt></b> <br> <li> <b><tt>lfs.chdir (path)</tt></b> <br>
Changes the current working directory to the given <tt>path</tt>.<br> Changes the current working directory to the given <tt>path</tt>.<br>
Returns <tt>true</tt> in case of success or <tt>nil</tt> plus an error Returns <tt>true</tt> in case of success or <tt>nil</tt> plus an error
string. string.
<a name="getcwd"></a> <a name="getcwd"></a>
<li> <b><tt>lfs.currentdir ()</tt></b> <br> <li> <b><tt>lfs.currentdir ()</tt></b> <br>
Returns a string with the current working directory or Returns a string with the current working directory or
<code>nil</code> plus an error string. <code>nil</code> plus an error string.
<a name="dir"></a> <a name="dir"></a>
<li> <b><tt>lfs.dir (path)</tt></b> <br> <li> <b><tt>lfs.dir (path)</tt></b> <br>
Lua iterator over the entries of a given directory. Lua iterator over the entries of a given directory.
Raises an error if <tt>path</tt> is not a directory. Raises an error if <tt>path</tt> is not a directory.
<a name="lock"></a> <a name="lock"></a>
<li> <b><tt>lfs.lock (filehandle, mode[, start[, length]])</tt></b> <br> <li> <b><tt>lfs.lock (filehandle, mode[, start[, length]])</tt></b> <br>
Locks a file or a part of it. Locks a file or a part of it.
This function works on <em>open files</em>; This function works on <em>open files</em>;
the file handle should be specified as the first argument. the file handle should be specified as the first argument.
The string <code>mode</code> could be either <code>r</code> (for a The string <code>mode</code> could be either <code>r</code> (for a
read/shared lock) or <code>w</code> (for a write/exclusive lock). read/shared lock) or <code>w</code> (for a write/exclusive lock).
The optional arguments <code>start</code> and <code>length</code> can be The optional arguments <code>start</code> and <code>length</code> can be
used to specify a starting point and its length; used to specify a starting point and its length;
both should be numbers.<br> both should be numbers.<br>
Returns a boolean indicating if the operation was successful; Returns a boolean indicating if the operation was successful;
in case of error, it returns <code>false</code> plus an error string. in case of error, it returns <code>false</code> plus an error string.
<a name="mkdir"></a> <a name="mkdir"></a>
<li> <b><tt>lfs.mkdir (dirname)</tt></b> <br> <li> <b><tt>lfs.mkdir (dirname)</tt></b> <br>
Creates a new directory. Creates a new directory.
The argument is the name of the new directory.<br> The argument is the name of the new directory.<br>
Returns a boolean indicating whether the operation succeeds or not Returns a boolean indicating whether the operation succeeds or not
(in this case, an error string is returned too). (in this case, an error string is returned too).
<a name="unlock"></a> <a name="unlock"></a>
<li> <b><tt>lfs.unlock (filehandle[, start[, length]])</tt></b> <br> <li> <b><tt>lfs.unlock (filehandle[, start[, length]])</tt></b> <br>
Unlocks a file or a part of it. Unlocks a file or a part of it.
This function works on <em>open files</em>; This function works on <em>open files</em>;
the file handle should be specified as the first argument. the file handle should be specified as the first argument.
The optional arguments <code>start</code> and <code>length</code> can be The optional arguments <code>start</code> and <code>length</code> can be
used to specify a starting point and its length; used to specify a starting point and its length;
both should be numbers.<br> both should be numbers.<br>
Returns a boolean indicating if the operation was successful; Returns a boolean indicating if the operation was successful;
in case of error, it returns <code>false</code> plus a string describing the in case of error, it returns <code>false</code> plus a string describing the
error. error.
</ul> </ul>
<a name="example"></a> <a name="example"></a>
<h2>Example</h2> <h2>Example</h2>
<pre> <pre>
require"lfs" require"lfs"
function attrdir (path) function attrdir (path)
for file in lfs.dir(path) do for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then if file ~= "." and file ~= ".." then
local f = path..'/'..file local f = path..'/'..file
print ("\t "..f) print ("\t "..f)
local attr = lfs.attributes (f) local attr = lfs.attributes (f)
assert (type(attr) == "table") assert (type(attr) == "table")
if attr.mode == "directory" then if attr.mode == "directory" then
attrdir (f) attrdir (f)
else else
for name, value in pairs(attr) do for name, value in pairs(attr) do
print (name, value) print (name, value)
end end
end end
end end
end end
end end
attrdir (".") attrdir (".")
</pre> </pre>
<a name="contents"></a> <a name="contents"></a>
<h2>Contents</h2> <h2>Contents</h2>
<p> <p>
<ul> <ul>
<li> <a href="#introduction">Introduction</a> <li> <a href="#introduction">Introduction</a>
<li> <a href="#reference">Reference</a> <li> <a href="#reference">Reference</a>
<ul> <ul>
<li> <a href="#chdir">chdir</a> <li> <a href="#chdir">chdir</a>
<li> <a href="#currentdir">currentdir</a> <li> <a href="#currentdir">currentdir</a>
<li> <a href="#dir">dir</a> <li> <a href="#dir">dir</a>
<li> <a href="#lock">lock</a> <li> <a href="#lock">lock</a>
<li> <a href="#mkdir">mkdir</a> <li> <a href="#mkdir">mkdir</a>
<li> <a href="#unlock">unlock</a> <li> <a href="#unlock">unlock</a>
</ul> </ul>
<li> <a href="#examples">Examples</a> <li> <a href="#examples">Examples</a>
</ul> </ul>
</p> </p>
<p> <p>
<center><small> <center><small>
<a href="index.html">home</a> &middot; <a href="index.html">home</a> &middot;
<a href="#introduction">introduction</a> &middot; <a href="#introduction">introduction</a> &middot;
<a href="#reference">reference</a> &middot; <a href="#reference">reference</a> &middot;
<a href="#example">example</a> <a href="#example">example</a>
</small></center> </small></center>
<p> <p>
<hr> <hr>
<small> <small>
$Id: manual.html,v 1.6 2004/11/05 10:37:29 tomas Exp $ $Id: manual.html,v 1.7 2004/11/10 14:09:45 tuler Exp $
</small> </small>
</body> </body>
</html> </html>