Nasal library/io: Difference between revisions

Jump to navigation Jump to search
io Core functions from former plausible.org added
(io Core functions from former plausible.org added)
Line 1: Line 1:
{{WIP}}
{{WIP}}
{{Nasal Navigation}}
{{Nasal Navigation}}
== Nasal Core functions ==
=== io.open(filename, mode="r") ===
Opens the file with the specified mode (as per ANSI fopen()) and returns a ghost object representing the filehandle. Failures are thrown as runtime errors as per die().
=== io.close(filehandle) ===
Closes the specified file as per ANSI fclose().
=== io.read(filehandle, buf, len) ===
Attempts to read length bytes from the filehandle into the beginning of the mutable string buf. Failures (including overruns when length > size(buf)) are thrown as runtime errors as per die(). Returns the number of bytes successfully read.
=== io.write(filehandle, str) ===
Attempts to write the entirety of the specified string to the filehandle. Failures are thrown as runtime errors as per die(). Returns the number of bytes successfully written.
=== io.seek(filehandle, position, whence)
As ANSI fseek(). Attempts to seek to the specified position based on the whence value (which must be one of io.SEEK_SET, io.SEEK_END, or io.SEEK_CUR).
=== io.tell(filehandle) ===
Returns the current seek position of the filehandle.
=== io.readln(filehandle) ===
Reads and returns a single text line from the filehandle. Interprets both "\n" and "\r\n" as end of line markers, and does not include the "\r" or "\n" bytes in the returned string. End of file or error is signaled by returning nil.
=== io.stat(filename) ===
Calls unix or win32 stat() on the specified file name and returns a seven element array whose contents are, in order: dev, ino, mode, nlink, uid, gid, rdef, size, atime, mtime, ctime. Errors are signaled as exceptions as per die().


== Creating files ==
== Writing files ==
== Reading files ==
== Reading files ==
The following description of functions refers to "$FG_ROOT\data\Nasal\io.nas".  
The following description of functions refers to "$FG_ROOT\data\Nasal\io.nas".  
546

edits

Navigation menu