1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <title>Reference
</title>
6 <link rel=
"stylesheet" href=
"../luadoc.css" type=
"text/css" />
7 <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
14 <div id=
"product_logo"></div>
15 <div id=
"product_name"><big><b></b></big></div>
16 <div id=
"product_description"></div>
17 </div> <!-- id="product" -->
27 <li><a href=
"../index.html">Index
</a></li>
38 <a href=
"../modules/luci.dispatcher.html">luci.dispatcher
</a>
42 <a href=
"../modules/luci.http.html">luci.http
</a>
46 <a href=
"../modules/luci.http.conditionals.html">luci.http.conditionals
</a>
50 <a href=
"../modules/luci.http.date.html">luci.http.date
</a>
54 <a href=
"../modules/luci.http.mime.html">luci.http.mime
</a>
58 <a href=
"../modules/luci.i18n.html">luci.i18n
</a>
62 <a href=
"../modules/luci.ip.html">luci.ip
</a>
66 <a href=
"../modules/luci.ip.cidr.html">luci.ip.cidr
</a>
70 <a href=
"../modules/luci.json.html">luci.json
</a>
74 <a href=
"../modules/luci.jsonc.html">luci.jsonc
</a>
78 <a href=
"../modules/luci.jsonc.parser.html">luci.jsonc.parser
</a>
82 <a href=
"../modules/luci.model.ipkg.html">luci.model.ipkg
</a>
86 <a href=
"../modules/luci.model.uci.html">luci.model.uci
</a>
90 <a href=
"../modules/luci.rpcc.html">luci.rpcc
</a>
94 <a href=
"../modules/luci.rpcc.ruci.html">luci.rpcc.ruci
</a>
98 <a href=
"../modules/luci.sys.html">luci.sys
</a>
102 <a href=
"../modules/luci.sys.init.html">luci.sys.init
</a>
106 <a href=
"../modules/luci.sys.iptparser.html">luci.sys.iptparser
</a>
110 <a href=
"../modules/luci.sys.net.html">luci.sys.net
</a>
114 <a href=
"../modules/luci.sys.process.html">luci.sys.process
</a>
118 <a href=
"../modules/luci.sys.user.html">luci.sys.user
</a>
122 <a href=
"../modules/luci.sys.wifi.html">luci.sys.wifi
</a>
126 <a href=
"../modules/luci.util.html">luci.util
</a>
130 <a href=
"../modules/nixio.html">nixio
</a>
134 <a href=
"../modules/nixio.CHANGELOG.html">nixio.CHANGELOG
</a>
138 <a href=
"../modules/nixio.CryptoHash.html">nixio.CryptoHash
</a>
141 <li><strong>nixio.File
</strong></li>
144 <a href=
"../modules/nixio.README.html">nixio.README
</a>
148 <a href=
"../modules/nixio.Socket.html">nixio.Socket
</a>
152 <a href=
"../modules/nixio.TLSContext.html">nixio.TLSContext
</a>
156 <a href=
"../modules/nixio.TLSSocket.html">nixio.TLSSocket
</a>
160 <a href=
"../modules/nixio.UnifiedIO.html">nixio.UnifiedIO
</a>
164 <a href=
"../modules/nixio.bin.html">nixio.bin
</a>
168 <a href=
"../modules/nixio.bit.html">nixio.bit
</a>
172 <a href=
"../modules/nixio.crypto.html">nixio.crypto
</a>
176 <a href=
"../modules/nixio.fs.html">nixio.fs
</a>
191 </div><!-- id="navigation" -->
195 <h1>Object Instance
<code>nixio.File
</code></h1>
199 Large file operations are supported up to
52 bits if the Lua number type is
200 double (default).
</p>
209 <table class=
"function_list">
212 <td class=
"name" nowrap
><a href=
"#File.close">File:close
</a> ()
</td>
214 Close the file descriptor.
</td>
218 <td class=
"name" nowrap
><a href=
"#File.fileno">File:fileno
</a> ()
</td>
220 Get the number of the filedescriptor.
</td>
224 <td class=
"name" nowrap
><a href=
"#File.lock">File:lock
</a> (command, length)
</td>
226 Apply or test a lock on the file.
</td>
230 <td class=
"name" nowrap
><a href=
"#File.read">File:read
</a> (length)
</td>
232 Read from a file descriptor.
</td>
236 <td class=
"name" nowrap
><a href=
"#File.seek">File:seek
</a> (offset, whence)
</td>
238 Reposition read / write offset of the file descriptor.
</td>
242 <td class=
"name" nowrap
><a href=
"#File.setblocking">File:setblocking
</a> (blocking)
</td>
244 (POSIX) Set the blocking mode of the file descriptor.
</td>
248 <td class=
"name" nowrap
><a href=
"#File.stat">File:stat
</a> (field)
</td>
250 Get file status and attributes.
</td>
254 <td class=
"name" nowrap
><a href=
"#File.sync">File:sync
</a> (data_only)
</td>
256 Synchronizes the file with the storage device.
</td>
260 <td class=
"name" nowrap
><a href=
"#File.tell">File:tell
</a> ()
</td>
262 Return the current read / write offset of the file descriptor.
</td>
266 <td class=
"name" nowrap
><a href=
"#File.write">File:write
</a> (buffer, offset, length)
</td>
268 Write to the file descriptor.
</td>
282 <h2><a name=
"functions"></a>Functions
</h2>
283 <dl class=
"function">
287 <dt><a name=
"File.close"></a><strong>File:close
</strong> ()
</dt>
290 Close the file descriptor.
298 <h3>Return value:
</h3>
308 <dt><a name=
"File.fileno"></a><strong>File:fileno
</strong> ()
</dt>
311 Get the number of the filedescriptor.
319 <h3>Return value:
</h3>
320 file descriptor number
329 <dt><a name=
"File.lock"></a><strong>File:lock
</strong> (command, length)
</dt>
332 Apply or test a lock on the file.
339 command: Locking Command [
"lock",
"tlock",
"ulock",
"test"]
343 length: Amount of Bytes to lock from current offset (optional)
354 <li>This function calls lockf() on POSIX and _locking() on Windows.
356 <li>The
"lock" command is blocking,
"tlock" is non-blocking,
357 "ulock" unlocks and
"test" only tests for the lock.
359 <li>The
"test" command is not available on Windows.
361 <li>Locks are by default advisory on POSIX, but mandatory on Windows.
367 <h3>Return value:
</h3>
377 <dt><a name=
"File.read"></a><strong>File:read
</strong> (length)
</dt>
380 Read from a file descriptor.
387 length: Amount of data to read (in Bytes).
398 <li><strong>Warning:
</strong> It is not guaranteed that all requested data
399 is read at once especially when dealing with pipes.
400 You have to check the return value - the length of the buffer actually read -
401 or use the safe IO functions in the high-level IO utility module.
403 <li>The length of the return buffer is limited by the (compile time)
404 nixio buffersize which is
<em>nixio.const.buffersize
</em> (
8192 by default).
405 Any read request greater than that will be safely truncated to this value.
411 <h3>Return value:
</h3>
412 buffer containing data successfully read
421 <dt><a name=
"File.seek"></a><strong>File:seek
</strong> (offset, whence)
</dt>
424 Reposition read / write offset of the file descriptor.
425 The seek will be done either from the beginning of the file or relative
426 to the current position or relative to the end.
437 whence: Starting point [
<strong>"set"</strong>,
"cur",
"end"]
446 This function calls lseek().
450 <h3>Return value:
</h3>
451 new (absolute) offset position
460 <dt><a name=
"File.setblocking"></a><strong>File:setblocking
</strong> (blocking)
</dt>
463 (POSIX) Set the blocking mode of the file descriptor.
480 <h3>Return value:
</h3>
490 <dt><a name=
"File.stat"></a><strong>File:stat
</strong> (field)
</dt>
493 Get file status and attributes.
500 field: Only return a specific field, not the whole table (optional)
509 This function calls fstat().
513 <h3>Return value:
</h3>
514 Table containing:
<ul>
515 <li>atime = Last access timestamp
</li>
516 <li>blksize = Blocksize (POSIX only)
</li>
517 <li>blocks = Blocks used (POSIX only)
</li>
518 <li>ctime = Creation timestamp
</li>
519 <li>dev = Device ID
</li>
520 <li>gid = Group ID
</li>
522 <li>modedec = Mode converted into a decimal number
</li>
523 <li>modestr = Mode as string as returned by
<code>ls -l
</code></li>
524 <li>mtime = Last modification timestamp
</li>
525 <li>nlink = Number of links
</li>
526 <li>rdev = Device ID (if special file)
</li>
527 <li>size = Size in bytes
</li>
528 <li>type = [
"reg",
"dir",
"chr",
"blk",
"fifo",
"lnk",
"sock"]
</li>
529 <li>uid = User ID
</li>
539 <dt><a name=
"File.sync"></a><strong>File:sync
</strong> (data_only)
</dt>
542 Synchronizes the file with the storage device.
543 Returns when the file is successfully written to the disk.
550 data_only: Do not synchronize the metadata. (optional, boolean)
561 <li>This function calls fsync() when data_only equals false
562 otherwise fdatasync(), on Windows _commit() is used instead.
564 <li>fdatasync() is only supported by Linux and Solaris. For other systems
565 the
<em>data_only
</em> parameter is ignored and fsync() is always called.
571 <h3>Return value:
</h3>
581 <dt><a name=
"File.tell"></a><strong>File:tell
</strong> ()
</dt>
584 Return the current read / write offset of the file descriptor.
591 This function calls lseek() with offset
0 from the current position.
595 <h3>Return value:
</h3>
605 <dt><a name=
"File.write"></a><strong>File:write
</strong> (buffer, offset, length)
</dt>
608 Write to the file descriptor.
615 buffer: Buffer holding the data to be written.
619 offset: Offset to start reading the buffer from. (optional)
623 length: Length of chunk to read from the buffer. (optional)
634 <li><strong>Warning:
</strong> It is not guaranteed that all data
635 in the buffer is written at once especially when dealing with pipes.
636 You have to check the return value - the number of bytes actually written -
637 or use the safe IO functions in the high-level IO utility module.
639 <li>Unlike standard Lua indexing the lowest offset and default is
0.
645 <h3>Return value:
</h3>
646 number of bytes written
659 </div> <!-- id="content" -->
661 </div> <!-- id="main" -->
664 <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>
665 </div> <!-- id="about" -->
667 </div> <!-- id="container" -->