Closes an open file.
Example:
# Example for fclose
var f=fopen("/tmp/file","r")
fclose(f)
Check if open file cursor is at end-of-file
Example:
# Example for feof
f=fopen("/tmp/file","r")
println feof(f)
fclose(f)
Flushes filehandle write buffer to disk.
Example:
# Example for fflush println fflush(f)
Returns the file mode attributes of a given file, or -1 on error.
Example:
# Example for file_mode
println file_mode("/tmp/file") # e.g., 33188
Returns the file size, in bytes, of a given file string, or -1 if the file cannot be checked.
Example:
# Example for file_size
println file_size("/tmp/f")
Attempts to place a file lock on file_handle.[#SOL]Lock type can be "r" (read), "w" (write) or "u" (unlock)
[#SOL]Returns true if the file could not be locked.
Opens a file and returns a file handle. mode can be either w (write), wa (write-append) or r (read).
Example:
# Example for fopen
var f=fopen("/tmp/file","r")
println f
Reads a string from an open file until delim is encountered (or end-of-file).
Example:
# Example for fread
f=fopen("/tmp/file","r")
println fread(f,"\n")
fclose(f)
Move the current position of reads or writes to an open file.
[#SOL]relativity indicates where the offset is relative to.
[#SOL](0:start of file,1:current position, 2:end of file) The newly sought position is returned.
Example:
# Example for fseek
var f=fopen("/tmp/file","r")
println fseek(f,10,0)
The current read pointer position is returned.
Example:
# Example for ftell
var f=fopen("/tmp/f","r")
println ftell(f)
Writes a string to an open file.
Example:
Returns true if file_name is a directory.
Example:
# Example for is_dir
println is_dir("/tmp") # true
Returns true if file_name is a regular file.
Example:
# Example for is_file
println is_file("/tmp/file") # true
Returns the file access permissions as an integer.
Example:
# Example for perms
println perms("/tmp") # e.g., 16877
Returns the contents of the named file string, or errors.
Example:
# Example for read_file
println read_file("/etc/hostname")
Returns a unix file stat structure containing underlying file information.
Writes the contents of wstring to file filename. Optionally sets the file permissions on new files. Returns true on success.
Example:
# Example for write_file
println write_file("/tmp/f","hi",0644)