C++ Native Functions: spl.file
- public stateful void clearerr (uint64 file)
-
Clear the error and end-of-file indicators for an open file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- public stateful int32 fclose (uint64 file, mutable int32 err)
-
Close a file.
- Parameters
-
- file
-
File to close (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- Returns
-
Return code from the system fclose() call.
- public stateful boolean feof (uint64 file)
-
Test if the stream is at the end of the file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- Returns
-
The value 'true' if the stream is at the end of the file.
- public stateful int32 fflush (uint64 file, mutable int32 err)
-
Flush a file to disk.
- Parameters
-
- file
-
File to flush (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- Returns
-
Return code from the system fflush() call.
- public stateful uint64 fopen (rstring filename, rstring mode, mutable int32 err)
-
Open a file.
- Parameters
-
- filename
-
File to open. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- mode
-
How the file is to be used (for reading, writing, etc), as required by the system fopen() call, for example, "r" for reading.
- err
-
Set to 0 on success, or the errno value on failure.
- Returns
-
The FILE* for the file, encoded as uint64.
- public stateful uint64 fopen (ustring filename, ustring mode, mutable int32 err)
-
Open a file.
- Parameters
-
- filename
-
File to open. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- mode
-
How the file is to be used (for reading, writing, etc), as required by the system fopen() call, for example, "r" for reading.
- err
-
Set to 0 on success, or the errno value on failure.
- Returns
-
The FILE* for the file, encoded as uint64.
- public stateful uint64 fread (mutable list<uint8> res, uint64 file, uint64 length, mutable int32 err)
-
Read a list of bytes from a file using binary format.
- Parameters
-
- res
-
List of bytes read.
- file
-
File (FILE* encoded as uint64).
- length
-
Number of bytes to be read.
- err
-
Set to 0 on success, or -1 if the end of the file is reached.
- Returns
-
Number of bytes read.
- <any T> public stateful void freadBin (mutable T res, uint64 file, mutable int32 err)
-
Read an SPL value from a file using binary format.
- Parameters
-
- res
-
Value to read from the file (assumed to have been written using fwriteBin).
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, -1 if the end of the file is reached, or EIO if there is an error deserializing the value.
- public stateful rstring freadLine (uint64 file, mutable int32 err)
-
Read a line from a file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or -1 if the end of the file is reached.
- Returns
-
The line read from the file (the new line character is not included).
- public stateful rstring freadToken (uint64 file, mutable int32 err)
-
Read a 'token' from a file. A token is a series of non-whitespace characters. Whitespace is skipped until a non-whitespace character is found, and then all non-whitespace characters in the token are returned.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or -1 if the end of the file is reached.
- Returns
-
The token read from the file. The token is empty if the end of the file is reached.
- <any T> public stateful void freadTxt (mutable T res, uint64 file, mutable int32 err)
-
Read an SPL value from a file as a text string.
- Parameters
-
- res
-
Value to read from the file (assumed to have been written using fwriteTxt).
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, -1 if the end of the file is reached, or EIO if there is an error deserializing the value.
- public stateful void freadfile (mutable blob res, uint64 file, mutable int32 err)
-
Read a whole file into a blob as binary.
- Parameters
-
- res
-
Blob of bytes read.
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- public stateful void fseek (uint64 file, int64 offset, int32 whence, mutable int32 err)
-
Set the current file position.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- offset
-
Position to seek to, as an offset in bytes.
- whence
-
Indicator specifying where position is relative to (optSEEK_SET(), optSEEK_CUR() or optSEEK_END()).
- err
-
Set to 0 on success, or the errno value on failure.
- public stateful void fstat (rstring file, rstring what, mutable timestamp result, mutable int32 err)
-
Return timestamp information about a file.
- Parameters
-
- file
-
File name. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- what
-
Desired information from the system call stat: one of "atime", "mtime", or "ctime".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful void fstat (rstring file, rstring what, mutable uint64 result, mutable int32 err)
-
Return information about a file.
- Parameters
-
- file
-
File name. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- what
-
Desired information from the system call stat: one of "dev", "rdev", "ino", "mode", "nlink", "uid", "gid", "size", "blksize", or "blocks".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful void fstat (uint64 file, rstring what, mutable timestamp result, mutable int32 err)
-
Return timestamp information about a file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- what
-
Desired information from the system call fstat: one of "atime", "mtime", or "ctime".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful void fstat (uint64 file, rstring what, mutable uint64 result, mutable int32 err)
-
Return information about a file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- what
-
Desired information from the system call fstat: one of "dev", "rdev", "ino", "mode", "nlink", "uid", "gid", "size", "blksize", or "blocks".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful void fstat (uint64 file, ustring what, mutable timestamp result, mutable int32 err)
-
Return timestamp information about a file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- what
-
Desired information from the system call fstat: one of "atime", "mtime", or "ctime".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful void fstat (uint64 file, ustring what, mutable uint64 result, mutable int32 err)
-
Return information about a file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- what
-
Desired information from the system call fstat: one of "dev", "rdev", "ino", "mode", "nlink", "uid", "gid", "size", "blksize", or "blocks".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful void fstat (ustring file, ustring what, mutable timestamp result, mutable int32 err)
-
Return timestamp information about a file.
- Parameters
-
- file
-
File name. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- what
-
Desired information from the system call stat: one of "atime", "mtime", or "ctime".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful void fstat (ustring file, ustring what, mutable uint64 result, mutable int32 err)
-
Return information about a file.
- Parameters
-
- file
-
File name. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- what
-
Desired information from the system call stat: one of "dev", "rdev", "ino", "mode", "nlink", "uid", "gid", "size", "blksize", or "blocks".
- result
-
Returned information.
- err
-
Set to 0 on success, or the errno value on failure (EINVAL if the what string is not valid).
- public stateful int64 ftell (uint64 file, mutable int32 err)
-
Return the current file position.
- Parameters
-
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- Returns
-
File position.
- public stateful void fwrite (list<uint8> val, uint64 file, uint64 loffset, uint64 length, mutable int32 err)
-
Write a list of bytes to a file using binary format.
- Parameters
-
- val
-
List containing the bytes to be written.
- file
-
File (FILE* encoded as uint64).
- loffset
-
Starting offset in the list.
- length
-
Number of elements in the list to be written.
- err
-
Set to 0 on success, or the errno value on failure.
- <any T> public stateful void fwriteBin (T val, uint64 file, mutable int32 err)
-
Write an SPL value to a file using binary format.
- Parameters
-
- val
-
Value to be written in serialized form.
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- <string T> public stateful void fwriteString (T val, uint64 file, mutable int32 err)
-
Write a string to a file.
- Parameters
-
- val
-
String value to be written.
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- <any T> public stateful void fwriteTxt (T val, uint64 file, mutable int32 err)
-
Write an SPL value to a file as a text string.
- Parameters
-
- val
-
Value to be written in serialized form.
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- public stateful void fwriteblob (blob b, uint64 file, mutable int32 err)
-
Write a blob into a file as binary.
- Parameters
-
- b
-
Blob of bytes to be written at the current position.
- file
-
File (FILE* encoded as uint64).
- err
-
Set to 0 on success, or the errno value on failure.
- public boolean isEACCES (int32 v)
-
Return whether the value is EACCES.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EACCES.
- public boolean isEAGAIN (int32 v)
-
Return whether the value is EAGAIN.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EAGAIN.
- public boolean isEBADF (int32 v)
-
Return whether the value is EBADF.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EBADF.
- public boolean isEFAULT (int32 v)
-
Return whether the value is EFAULT.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EFAULT.
- public boolean isEFBIG (int32 v)
-
Return whether the value is EFBIG.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EFBIG.
- public boolean isEINTR (int32 v)
-
Return whether the value is EINTR.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EINTR.
- public boolean isEINVAL (int32 v)
-
Return whether the value is EINVAL.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EINVAL.
- public boolean isEIO (int32 v)
-
Return whether the value is EIO.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EIO.
- public boolean isEISDIR (int32 v)
-
Return whether the value is EISDIR.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EISDIR.
- public boolean isELOOP (int32 v)
-
Return whether the value is ELOOP.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ELOOP.
- public boolean isEMFILE (int32 v)
-
Return whether the value is EMFILE.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EMFILE.
- public boolean isENAMETOOLONG (int32 v)
-
Return whether the value is ENAMETOOLONG.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENAMETOOLONG.
- public boolean isENFILE (int32 v)
-
Return whether the value is ENFILE.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENFILE.
- public boolean isENODEV (int32 v)
-
Return whether the value is ENODEV.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENODEV.
- public boolean isENOENT (int32 v)
-
Return whether the value is ENOENT.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENOENT.
- public boolean isENOMEM (int32 v)
-
Return whether the value is ENOMEM.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENOMEM.
- public boolean isENOSPC (int32 v)
-
Return whether the value is ENOSPC.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENOSPC.
- public boolean isENOTDIR (int32 v)
-
Return whether the value is ENOTDIR.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENOTDIR.
- public boolean isENXIO (int32 v)
-
Return whether the value is ENXIO.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ENXIO.
- public boolean isEOF (int32 v)
-
Return whether the value is EOF.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EOF.
- public boolean isEOVERFLOW (int32 v)
-
Return whether the value is EOVERFLOW.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EOVERFLOW.
- public boolean isEPERM (int32 v)
-
Return whether the value is EPERM.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EPERM.
- public boolean isEPIPE (int32 v)
-
Return whether the value is EPIPE.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EPIPE.
- public boolean isEROFS (int32 v)
-
Return whether the value is EROFS.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EROFS.
- public boolean isESPIPE (int32 v)
-
Return whether the value is ESPIPE.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ESPIPE.
- public boolean isETXTBSY (int32 v)
-
Return whether the value is ETXTBSY.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is ETXTBSY.
- public boolean isEWOULDBLOCK (int32 v)
-
Return whether the value is EWOULDBLOCK.
- Parameters
-
- v
-
Value.
- Returns
-
The value 'true' if the value is EWOULDBLOCK.
- public stateful void mkdir(rstring name, uint32 mode, mutable int32 err)
-
Create a directory
- Parameters
-
- name
-
Directory name. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- mode
-
The permissions to be set on the new directory. This should have the equivalent values that would be passed to the C mkdir function.
- err
-
Set to 0 on success, or the errno value on failure.
- public int32 optSEEK_CUR()
-
Return the indicator for specifying to seek relative to the current file position.
- Returns
-
The SEEK_CUR indicator.
- public int32 optSEEK_END()
-
Return the indicator for specifying to seek relative to the end of the file.
- Returns
-
The SEEK_END indicator.
- public int32 optSEEK_SET()
-
Return the indicator for specifying to seek relative to the start of the file.
- Returns
-
The SEEK_SET indicator.
- public stateful void remove (rstring name, mutable int32 err)
-
Remove a file or directory.
- Parameters
-
- name
-
File or directory name. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- err
-
Set to 0 on success, or the errno value on failure.
- public stateful void remove (ustring name, mutable int32 err)
-
Remove a file or directory.
- Parameters
-
- name
-
File or directory name. This must be a fully qualified name. You can use built-in functions like dataDirectory to construct the fully qualified name.
- err
-
Set to 0 on success, or the errno value on failure.
- public stateful void rewind (uint64 file)
-
Set the current file position to the start of the file.
- Parameters
-
- file
-
File (FILE* encoded as uint64).