aboutsummaryrefslogtreecommitdiff
path: root/doc/us/manual.html
blob: ecc5cb4f55c40ac3e2a716d5080ee2be4b447bac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>LuaFileSystem</title>
    <link rel="stylesheet" href="http://www.keplerproject.org/doc.css" type="text/css"/>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>

<body>

<div id="container">

<div id="product">
	<div id="product_logo"><a href="http://www.keplerproject.org">
		<img alt="LuaFileSystem" src="luafilesystem.png"/>
	</a></div>
	<div id="product_name"><big><strong>LuaFileSystem</strong></big></div>
	<div id="product_description">File System Library for the Lua Programming Language</div>
</div> <!-- id="product" -->

<div id="main">
	
<div id="navigation">
<h1>LuaFileSystem</h1>
	<ul>
		<li><a href="index.html">Home</a>
			<ul>
				<li><a href="index.html#overview">Overview</a></li>
				<li><a href="index.html#status">Status</a></li>
				<li><a href="index.html#download">Download</a></li>
				<li><a href="index.html#history">History</a></li>
				<li><a href="index.html#credits">Credits</a></li>
				<li><a href="index.html#contact">Contact us</a></li>
			</ul>
		</li>
		<li><strong>Manual</strong>
			<ul>
				<li><a href="manual.html#introduction">Introduction</a></li>
				<li><a href="manual.html#installation">Installation</a></li>
				<li><a href="manual.html#reference">Reference</a></li>
			</ul>
		</li>
		<li><a href="examples.html">Examples</a></li>
		<li><a href="license.html">License</a></li>
	</ul>
</div> <!-- id="navigation" -->

<div id="content">

<h2><a name="introduction"></a>Introduction</h2>

<p>LuaFileSystem is a <a href="http://www.lua.org">Lua</a> library
developed to complement the set of functions related to file
systems offered by the standard Lua distribution.</p>

<p>LuaFileSystem offers a portable way to access
the underlying directory structure and file attributes.<p>

<h2><a name="installation"></a>Installation</h2>

<p>
LuaFileSystem is distributed as a pair of C source and header
files. The distribution provides a <code>Makefile</code> prepared to
compile the library and install it. The file <code>config</code> should
be edited to suit the needs of the aimed platform.
</p>

<p>
LuaFileSystem follows the
<a href="http://www.keplerproject.org/compat">package proposal</a>
for Lua 5.1, therefore this package should be "installed".
In other words,
if you are using Lua 5.0, the files <code>compat-5.1.c</code> and
<code>compat-5.1.h</code> must be used in the compilation and the file
<code>compat-5.1.lua</code> must be installed in the <code>LUA_PATH</code>.
If you are using Lua 5.1, nothing should be done.</p>

<h2><a name="reference"></a>Reference</h2>

<p>LuaFileSystem offers the following functions:</p>

<dl>
    <dt><a name="attributes"></a><strong><code>lfs.attributes (filepath)</code></strong></dt>
    <dd>Returns a table with the file attributes corresponding to <code>filepath</code>.
    The attributes are: 
        <dl>
        <dt><strong><code>dev</code></strong></dt>
        <dd>device that the inode resides on</dd>
        
        <dt><strong><code>ino</code></strong></dt>
        <dd>inode's number</dd>
        
        <dt><strong><code>mode</code></strong></dt>
        <dd>inode protection mode (string, values could be <code>file</code>,
        <code>directory</code>, <code>link</code>, <code>socket</code>,
        <code>named pipe</code>, <code>char device</code>, <code>block device</code> or
        <code>other</code>)</dd>
        
        <dt><strong><code>nlink</code></strong></dt>
		<dd>number of hard links to the file</dd>

        <dt><strong><code>uid</code></strong></dt>
		<dd>user-id of owner</dd>

        <dt><strong><code>gid</code></strong></dt>
		<dd>group-id of owner</dd>

        <dt><strong><code>rdev</code></strong></dt>
		<dd>device type, for special file inode</dd>

        <dt><strong><code>access</code></strong></dt>
		<dd>time of last access</dd>

        <dt><strong><code>modification</code></strong></dt>
		<dd>time of last data modification</dd>

        <dt><strong><code>change</code></strong></dt>
		<dd>time of last file status change</dd>

        <dt><strong><code>size</code></strong></dt>
		<dd>file size, in bytes</dd>

        <dt><strong><code>blocks</code></strong></dt>
		<dd>block allocated for file; (Unix only)</dd>
        
        <dt><strong><code>blksize</code></strong></dt>
		<dd>optimal file system I/O blocksize; (Unix only)</dd>
    </dl>


    <dt><a name="chdir"></a><strong><code>lfs.chdir (path)</code></strong></dt>
    <dd>Changes the current working directory to the given
    <code>path</code>.<br />
    Returns <code>true</code> in case of success or <code>nil</code> plus an
    error string.</dd>
    
    
    <dt><a name="getcwd"></a><strong><code>lfs.currentdir ()</code></strong></dt>
    <dd>Returns a string with the current working directory or <code>nil</code>
    plus an error string.</dd>
    
    <dt><a name="dir"></a><strong><code>lfs.dir (path)</code></strong></dt>
    <dd>Lua iterator over the entries of a given directory. Raises an
    error if <code>path</code> is not a directory.</dd>
    
    <dt><a name="lock"></a><strong><code>lfs.lock (filehandle, mode[, start[, length]])</code></strong></dt>
    <dd>Locks a file or a part of it. This function works on <em>open files</em>; the
    file handle should be specified as the first argument.
    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). The optional arguments <code>start</code>
    and <code>length</code> can be used to specify a starting point and
    its length; both should be numbers.<br />
    Returns a boolean indicating if the operation was successful; in
    case of error, it returns <code>false</code> plus an error string.
    </dd>
    
    <dt><a name="mkdir"></a><strong><code>lfs.mkdir (dirname)</code></strong></dt>
    <dd>Creates a new directory. The argument is the name of the new
    directory.<br />
    Returns a boolean indicating whether the operation succeeds or not
    (in this case, an error string is returned too).</dd>
    
    <dt><a name="touch"></a><strong><code>lfs.touch (filepath [, atime [, mtime]])</code></strong></dt>
    <dd>Set access and modification times of a file. This function is
    a bind to <code>utime</code> function. The first argument is the
    filename, the second argument (<code>atime</code>) is the access time,
    and the third argument (<code>mtime</code>) is the modification time.
    Both times are provided in seconds (which should be generated with
    Lua standard function <code>os.date</code>).
    If the modifition time is omitted, the access time provided is used;
    if both times are omitted, the current time is used.<br />
    Returns a boolean indicating whether the operation succeeded or not
    (followed by an error string when it fails).</dd>
    
    <dt><a name="unlock"></a><strong><code>lfs.unlock (filehandle[, start[, length]])</code></strong></dt>
    <dd>Unlocks a file or a part of it. This function works on
    <em>open files</em>; the file handle should be specified as the first
    argument. The optional arguments <code>start</code> and
    <code>length</code> can be used to specify a starting point and its
    length; both should be numbers.<br />
    Returns a boolean indicating if the operation was successful; in
    case of error, it returns <code>false</code> plus a string
    describing the error.</dd>
</dl>

</div> <!-- id="content" -->

</div> <!-- id="main" -->

<div id="about">
	<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
	<p><small>
	$Id: manual.html,v 1.14 2005/05/20 18:04:56 uid20002 Exp $
	</small></p>
</div> <!-- id="about" -->

</div> <!-- id="container" -->

</body>
</html>