Note: This class is not available with the PO_NO_FILESYSTEM parse option.
The File class allows Qore programs to read, write, and create files.
File objects can be created and/or opened with a specific character encoding, meaning that any string read from the file will be tagged with the file's character encoding, and any string data written to the file will be transparently converted to that character encoding before being written (if necessary). If no character encoding is specified, then the default Qore character encoding is assumed for the file.
This class supports posting events to a Queue. See Event Handling for more information.
The events raised by this object are listed in the following table:
Table 4.26. File Events
Name | Description |
|---|---|
Raised when data is read from the file. | |
Raised when data is written to the file. | |
Raised when the file is closed. | |
Raised when the object being monitored is deleted. | |
Raised right before an attempt to open a file is made. | |
Raised when the file has been successfully opened. |
Table 4.27. File Method Overview
Method | Except? | Description |
|---|---|---|
| N | Creates the object and optionally sets the file's character encoding. |
N | Closes the file if it is open and destroys the file object. | |
N | Creates a new file object with the same character encoding specification as the original, otherwise no other information is copied. | |
| Y | Changes the user and group owners of the file on the filesystem (if the current user has sufficient permission to do so). |
N | Closes the file object | |
| Y | Writes a formatted string to a file, enforces hard field limits. |
| Y | Writes a formatted string to a file, where the second argument is the formatting argument list, enforces hard field limits. |
N | Reads one character from the file; returns NOTHING if no data can be read from the file. | |
N | Returns the character encoding for the file | |
Y | Returns a hash of lock information. | |
N | Gets the current file position (in bytes) | |
Y | Saves the current terminal attributes for the file in the TermIOS object passed; changes the object passed to reflect the terminal attributes as set for the file. | |
Y | Returns a Stat Hash about the file's status or throws an exception if any errors occur. | |
| Y | Returns True if there is data available for reading from the file within the timeout period. |
| Y | Attempts to lock the file according to the arguments passed, does not block. |
| Y | Attempts to lock the file according to the arguments passed, blocking. |
| Y | Opens a file in a particular mode, returns an error code on failure. |
| Y | Opens a file in a particular mode; throws an exception on failure. |
| Y | Writes a formatted string to a file. |
| Y | Reads a certain number of bytes from the file within an optional timeout period and returns a string of the data read or NOTHING if no data can be read. |
| Y | Reads a certain number of bytes from the file within an optional timeout period and returns binary data or NOTHING if no data can be read. |
Y | Reads a 1-byte signed integer from the file or NOTHING if no data can be read. | |
Y | Reads a 2-byte signed integer from the file in big-endian format or NOTHING if no data can be read. | |
Y | Reads a 4-byte signed integer from the file in big-endian format or NOTHING if no data can be read. | |
Y | Reads an 8-byte signed integer from the file in big-endian format or NOTHING if no data can be read. | |
Y | Reads a 2-byte signed integer from the file in little-endian format or NOTHING if no data can be read. | |
Y | Reads a 4-byte signed integer from the file in little-endian format or NOTHING if no data can be read. | |
Y | Reads an 8-byte signed integer from the file in little-endian format or NOTHING if no data can be read. | |
Y | Reads a 1-byte unsigned integer from the file or NOTHING if no data can be read. | |
Y | Reads a 2-byte unsigned integer from the file in big-endian format or NOTHING if no data can be read. | |
Y | Reads a 4-byte unsigned integer from the file in big-endian format or NOTHING if no data can be read. | |
Y | Reads a 2-byte unsigned integer from the file in little-endian format or NOTHING if no data can be read. | |
Y | Reads a 4-byte unsigned integer from the file in little-endian format or NOTHING if no data can be read. | |
Y | Reads until an EOL marker is found and returns the string read or NOTHING if no data can be read. | |
| N | Sets the character encoding for the file; if passed with no argument, the default encoding is set. |
| N | Sets the current file position (in bytes). |
| Y | Sets the current terminal attributes for the file from the TermIOS object passed; does not change the object passed. |
Y | Returns a Stat List about the file's status or throws an exception if any errors occur. | |
Y | Returns a Filesystem Status Hash about the file's filesystem status or throws an exception if any errors occur. | |
N | Flushes the file's buffer to disk. | |
| Y | Writes a formatted string to a file, where the second argument is the formatting argument list. |
| Y | Writes string or binary data to a file |
| Y | Writes a 1-byte integer to the file. |
| Y | Writes a 2-byte integer in big-endian format. |
| Y | Writes a 4-byte integer in big-endian format. |
| Y | Writes an 8-byte integer in big-endian format. |
| Y | Writes a 2-byte integer in little-endian format. |
| Y | Writes a 4-byte integer in little-endian format. |
| Y | Writes an 8-byte integer in little-endian format. |
| Y | Returns a Stat Hash about the given path's status (does not follow symbolic links) or throws an exception if any errors occur. |
| Y | Returns a Stat Hash about the given path's status (follows symbolic links) or throws an exception if any errors occur. |
| Y | Returns a Stat List about given path's status (does not follow synbolic links) or throws an exception if any errors occur. |
| Y | Returns a Stat List about given path's status (follows symbolic links) or throws an exception if any errors occur. |
| Y | Returns a Filesystem Status Hash about the given path's filesystem status or throws an exception if any errors occur. |
Table 4.31. Stat Constants in the Qore Namespace
Creates the File object. It accepts one optional argument that will set the default character encoding for the file (only affects reading and writing string data).
File::constructor(string$encoding)
my File $f("ISO-8859-1"); # specify ISO-8859-1 encoding for the fileTable 4.32. Arguments for File::constructor()
Argument | Type | Description |
|---|---|---|
| The character encoding for the file. Any strings written to the file will be converted to this character encoding if necessary. |
Closes the file if it's open and destroys the File object.
delete $f;Creates a new File object with the same character encoding specification as the original.
my File $f1 = $f.copy();Changes the file's user and group owner (if the user has sufficient permissions to do so).
nothingFile::chown(softint$uid, softint$gid = -1)
$f.chown(0, 0);
Table 4.34. Return Value for File::chown()
Return Type | Description |
|---|---|
n/a | This method does not return a value; if an error occurs, an exception is thrown. |
Table 4.35. Exceptions Thrown by File::chown()
err | desc |
|---|---|
| File is not open or the chown operation failed. |
| This exception is thrown when the method is not available on the runtime platform; for maximum portability, check the constant |
Closes the file object if it's open. Note that this is automatically called by File::destructor().
$f.close();
Table 4.36. Return Value for File::close()
Return Type | Description |
|---|---|
0 for success, -1 for an error (see errno() and strerror() for the error information) |
Writes a formatted string to a file, enforces hard field limits (similar to the f_printf() function). See String Formatting for more information about the format string.
intFile::f_printf(string$fmt, ...)
$f.f_printf("%5s\n", "long string"); # will print "long \n", respecting the 5-character field widthTable 4.37. Arguments for File::f_printf()
Argument | Description |
|---|---|
| The format string, see String Formatting for a specification. |
| The remainder of the arguments are arguments to the format string. |
Table 4.38. Return Value for File::f_printf()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes a formatted string to a file, where the second argument is the formatting argument list, enforces hard field limits. See String Formatting for more information about the format string.
intFile::f_vprintf(string$fmt, any$args)
$f.f_vprintf("%5s %3d\n", ("a long string", 5000)); # outputs "a lon 500", truncating outputTable 4.40. Arguments for File::f_vprintf()
Argument | Description |
|---|---|
| The format string, see String Formatting for a specification. |
| This single argument or list of arguments will be used as the argument list or the format string. If a single argument is passed instead of a list, it will be used as the first argument as if a list were passed. |
Table 4.41. Return Value for File::f_vprintf()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Reads one character from the file and returns it as a one-character string. Returns NOTHING if no data can be read from the file.
my *string $str = $f.getchar();Returns the character encoding for the file.
$encoding = $f.getCharset();
Table 4.44. Return Value for File::getCharset()
Return Type | Description |
|---|---|
The character encoding for the file. |
Returns a hash of lock information for the file. The hash contains the following keys: start, len, pid, type, whence. If no lock is set on the file, the key type has the value F_UNLCK.
my hash $hash = $f.getLockInfo();Table 4.46. Exceptions Thrown by File::getLockInfo()
err | desc |
|---|---|
| File is not open or the fcntl operation failed. |
Gets the current file position as an integer giving the offset in bytes from the beginning of the file (starting from zero).
$pos = $f.getPos();
Table 4.47. Return Value for File::getPos()
Return Type | Description |
|---|---|
The byte position in the file starting at 0. |
Saves the current terminal attributes for the file in the TermIOS object passed; changes the object passed to reflect the terminal attributes as set for the file. Do not pass a reference to the TermIOS object; pass the object itself.
my TermIOS $termios();
stdin.getTerminalAttributes($termios);Table 4.48. Arguments for File::getTerminalAttributes()
Argument | Description |
|---|---|
| The method writes the current terminal attributes for the file to the object passed. |
Table 4.49. Exceptions Thrown by File::getTerminalAttributes()
err | desc |
|---|---|
| The file is not open. |
| Error reading terminal attributes from the file descriptor. |
Returns a hash of file status values for the current file.
If any errors occur, a FILE-HSTAT-ERROR exception is thrown.
See also static File::hstat().
my hash $h = $file.hstat();Not available with PO_NO_FILESYSTEM
Table 4.50. Return Values for File::hstat()
Return Type | Description | |
|---|---|---|
Returns a hash of file status values for the current file (must be open); if any errors occur, an exception is thrown. See also static File::hstat(). See Stat Hash for a description of the hash returned by this method. |
Table 4.51. Exceptions Thrown by File::hstat()
err | desc |
|---|---|
|
|
Returns True is data becomes available for reading on the file within a timeout period. With a timeout of zero (the default if no timeout value is passed), this method can be used for non-blocking polling the file for data. Like all Qore functions and methods taking timeout values, a relative time value may be passed instead of an integer to make the timeout units clear (ex: 25ms).
boolFile::isDataAvailable(timeout$timeout_ms = 0)
my bool $b = $file.isDataAvailable(0); # returns True if data is available nowTable 4.52. Arguments for File::isDataAvailable()
Argument | Description |
|---|---|
| An optional timeout in milliseconds (1/1000 second). |
Table 4.53. Return Values for File::isDataAvailable()
Return Type | Description |
|---|---|
True if data becomes available for reading from the file within the timeout period, |
Locks or unlocks a portion of the file or the entire file, for reading or writing, non-blocking. The file must be opened in the appropriate mode before this call or the call will fail with an exception. For a blocking version of this method, see File::lockBlocking().
intFile::lock(softint$type = F_RDLCK, softint$start = 0, softint$len = 0, softint$whence = SEEK_SET)
# lock the entire file exclusively $f.lock(F_WRLCK); # lock a section of the file for reading, start byte 512, 2K range $f.lock(F_RDLCK, 512, 2048); # release all locks $f.lock(F_UNLCK);
Table 4.55. Arguments for File::lock()
Argument | Description |
|---|---|
Type of lock (or unlock); see File locking constants. | |
| Start byte for lock, 0 is the default (start of file). |
| Length in bytes for range to lock, 0 is the default (rest of file). |
Indicates how the relative offset of the file should be calculated for the lock; see File seek constants. |
Table 4.56. Return Value for File::lock()
Return Type | Description |
|---|---|
Returns 0 for success, |
Table 4.57. Exceptions Thrown by File::lock()
err | desc |
|---|---|
| File is not open, lock length is negative, or the fcntl operation failed. |
| This exception is thrown when the method is not available on the runtime platform; for maximum portability, check the constant |
Locks or unlocks a portion of the file or the entire file, for reading or writing, blocking. The file must be opened in the appropriate mode before this call or the call will fail with an exception. For a non-blocking version of this method, see File::lock().
nothingFile::lockBlocking(softint$type = F_RDLCK, softint$start = 0, softint$len = 0, softint$whence = SEEK_SET)
# lock the entire file exclusively $f.lockBlocking(F_WRLCK); # lock a section of the file for reading, start byte 512, 2K range $f.lockBlocking(F_RDLCK, 512, 2048); # release all locks $f.lockBlocking(F_UNLCK);
Table 4.58. Arguments for File::lockBlocking()
Argument | Description |
|---|---|
Type of lock (or unlock), see File locking constants. | |
| Start byte for lock, 0 is the default (start of file). |
| Length in bytes for range to lock, 0 is the default (rest of file). |
Indicates how the relative offset of the file should be calculated for the lock; see File seek constants. |
Table 4.59. Return Value for File::lockBlocking()
Return Type | Description |
|---|---|
n/a | This method does not return a value; exceptions are thrown if errors occur. |
Table 4.60. Exceptions Thrown by File::lockBlocking()
err | desc |
|---|---|
| File is not open, lock length is negative, or the fcntl operation failed. |
| This exception is thrown when the method is not available on the runtime platform; for maximum portability, check the constant |
Writes a formatted string with soft field widths to the file. See File::f_printf() for a similar method that enforces field widths. See String Formatting for more information about the format string.
intFile::printf(string$fmt, ...)
$f.printf("%5s\n", "hello there"); # outputs "hello there\n", exceeding field widthTable 4.61. Arguments for File::printf()
Argument | Description |
|---|---|
| The format string, see String Formatting for a specification. |
... | The remainder of the arguments are arguments to the format string. |
Table 4.62. Return Value for File::printf()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Opens the file in the mode given. Aditionally, the file permissions can be given if the file is to be created, and optionally the file's default character encoding can be specified.
Note that if no encoding is specified, the file will be tagged with the default character encoding for the process. Any string data written to the file will be converted to the file's encoding, and any string data read from the file will be automatically tagged with the file's encoding.
For a version of this method that throws an exception when errors occur opening the file, see File::open2().
intFile::open(string$path, softint$flags = O_RDONLY, softint$mode = 0666)
intFile::open(string$path, softint$flags = O_RDONLY, softint$mode = 0666, string$encoding)
# open a file for writing, truncate data if already exists, create the file if doesn't exist
# set 0644 permissions, and convert all string data to ISO-8859-1 encoding
$f.open("new_file.txt", O_CREAT | O_TRUNC | O_WRONLY, 0644, "ISO-8859-1");Table 4.64. Arguments for File::open()
Argument | Description |
|---|---|
| The path to the file. |
Flags that determine the way the file is accessed, see File Constants for more information. If this argument is not given, | |
| Permission bits for when the file is to be created (default: 0666) |
| The name of the default character encoding for this file; if this argument is not given, the file will be tagged with the default character encoding for the process. |
Table 4.65. Return Values for File::open()
Return Type | Description |
|---|---|
0 = no error, -1 = see errno() and strerror() for the error message |
This method does not throw any exceptions.
Opens the file in the mode given. Aditionally, the file permissions can be given if the file is to be created, and optionally the file's default character encoding can be specified.
Note that if no encoding is specified, the file will be tagged with the default character encoding for the process. Any string data written to the file will be converted to the file's encoding, and any string data read from the file will be automatically tagged with the file's encoding.
If an error occurs, a FILE-OPEN2-ERROR exception is thrown. For a version of this method that returns an error code, see File::open().
nothingFile::open2(string$path, softint$flags = O_RDONLY, softint$mode = 0666)
nothingFile::open2(string$path, softint$flags = O_RDONLY, softint$mode = 0666, string$encoding)
# open a file for writing, truncate data if already exists, create the file if doesn't exist
# set 0644 permissions, and convert all string data to ISO-8859-1 encoding
$f.open2("new_file.txt", O_CREAT | O_TRUNC | O_WRONLY, 0644, "ISO-8859-1");Table 4.66. Arguments for File::open2()
Argument | Description |
|---|---|
| The path to the file. |
Flags that determine the way the file is accessed, see File Constants for more information. If this argument is not given, | |
| Permission bits for when the file is to be created (default: 0666) |
| The name of the default character encoding for this file; if this argument is not given, the file will be tagged with the default character encoding for the process. |
Table 4.67. Exceptions Thrown by File::open2()
err | desc |
|---|---|
| Error opening the file; attempted to reopen a system file (I/O constants). |
Reads a certain amount of string data from the file; the size argument is required. To read binary data, use the File::readBinary() method.
Note that the amount of data read from the file may be less than the size given, for example if the file does not contain enough data to fulfill the request. In this case, only the data available in the file is returned.
An optional timeout period in milliseconds can be passed as well (or a relative time value may be passed instead of an integer to make the timeout units clear; ex: 25ms). If a timeout value is passed and the data cannot be read within the timeout period, then a FILE-READ-TIMEOUT exception is thrown. If no timeout value is passed or a negative value is given, then the call will never timeout until either the requested amount of data has been read from the file or an end-of-file condition has been reached.
*stringFile::read(softint$size, timeout$timeout_ms = -1)
my *string $data = $f.read(-1); # read an entire text file into a variableTable 4.68. Arguments for File::read()
Argument | Description |
|---|---|
| The number of bytes to read of the file, -1 will read the entire file. |
| A timeout period with a resolution of milliseconds (an integer argument will be assumed to be milliseconds)); if not given or negative the call will never time out and will only return when the data has been read. |
Table 4.70. Exceptions Thrown by File::read()
err | desc |
|---|---|
| Zero size argument passed. |
| File is not open; timeout limit exceeded. |
Reads a 1-byte signed integer from the file and returns the integer value read.
my *int $i = $f.readi1();Reads a 2-byte signed integer from the file in big-endian (MSB, network byte order) format. See File::readi2LSB() for an equivalent method reading a 2-byte signed integer in little-endian (LSB) format.
my *int $i = $f.readi2();Reads a 4-byte signed integer from the file in big-endian format. See File::readi4LSB() for an equivalent method reading a 4-byte signed integer in little-endian (LSB) format.
my *int $i = $f.readi4();Reads a 4-byte signed integer from the file in big-endian format. See File::readi8LSB() for an equivalent method reading a 4-byte signed integer in little-endian (LSB) format.
my *int $i = $f.readi8();Reads a 2-byte signed integer from the file in little-endian (LSB) format. See File::readi2() for an equivalent method reading a 2-byte signed integer in big-endian (MSB, network byte order) format.
my *int $i = $f.readi2LSB();Reads a 4-byte signed integer from the file in little-endian format. See File::readi4() for an equivalent method reading a 4-byte signed integer in big-endian (MSB, network byte order) format.
my *int $i = $f.readi4LSB();Reads an 8-byte signed integer from the file in little-endian format. See File::readi8() for an equivalent method reading a 8-byte signed integer in big-endian (MSB, network byte order) format.
my *int $i = $f.readi8LSB();Reads a 1-byte unsigned integer from the file and returns the integer value read.
my *int $i = $f.readu1();Reads a 2-byte signed integer from the file in big-endian (MSB, network byte order) format. See File::readu2LSB() for an equivalent method reading a 2-byte signed integer in little-endian (LSB) format.
my *int $i = $f.readu2();Reads a 4-byte signed integer from the file in big-endian format. See File::readu4LSB() for an equivalent method reading a 4-byte signed integer in little-endian (LSB) format.
my *int $i = $f.readu4();Reads a 2-byte signed integer from the file in little-endian (LSB) format. See File::readu2() for an equivalent method reading a 2-byte signed integer in big-endian (MSB, network byte order) format.
my *int $i = $f.readu2LSB();Reads a 4-byte unsigned integer from the file in little-endian format. See File::readu4() for an equivalent method reading a 4-byte signed integer in big-endian (MSB, network byte order) format or NOTHING if no data can be read.
my *int $i = $f.readu4LSB();Read a certain amount of data and return a binary object; the size parameter is mandatory.
Note that the amount of data read from the file may be less than the size given, for example if the file does not contain enough data to fulfill the request. In this case, only the data available in the file is returned.
An optional timeout period in milliseconds can be passed as well (or a relative time value may be passed instead of an integer to make the timeout units clear; ex: 25ms). If a timeout value is passed and the data cannot be read within the timeout period, then a FILE-READ-TIMEOUT exception is thrown. If no timeout value is passed or a negative value is given, then the call will never timeout until either the requested amount of data has been read from the file or an end-of-file condition has been reached.
*binaryFile::readBinary(softint$size, timeout$timeout_ms = 1)
my *binary $data = $f.readBinary(); # reads an entire binary file into a variableTable 4.97. Exceptions Thrown by File::readBinary()
err | desc |
|---|---|
| Zero size argument passed. |
| File is not open; timeout limit exceeded. |
Reads until an EOL marker is found and returns a string containing the EOL marker. Returns NOTHING on end of file.
while (exists (my *string $line = $f.readLine())) { # remove EOL marker chomp $line; # print out the line just read printf("%s\n", $line); }
Sets the characte encoding for the file.
nothingFile::setCharset(string$encoding)
$f.setCharset("ISO-8859-1");Table 4.100. Arguments for File::setCharset()
Argument | Description |
|---|---|
| The character encoding for the file. |
Sets the current file position in bytes starting with zero.
intFile::setPos(softint$pos = 0)
$f.setPos(0); # go to the beginning of the file
Table 4.101. Arguments for File::setPos()
Argument | Description |
|---|---|
| The position in the file as offset from position 0. |
Table 4.102. Return Value for File::setPos()
Return Type | Description |
|---|---|
Returns the new offset in the file, -1 for error. |
Sets the terminal attributes for the file from the TermIOS object passed; does not change the object passed.
nothingFile::setTerminalAttributes(softint$action = TCSANOW, TermIOS$termios)
my TermIOS $termios(); stdin.getTerminalAttributes($termios); my TermIOS $orig = $termios.copy(); on_exit stdin.setTerminalAttributes(TCSADRAIN, $orig); my $lflag = $termios.getLFlag(); $lflag &= ~ICANON; $lflag &= ~ECHO; $lflag &= ~ISIG; $termios.setLFlag($lflag); $termios.setCC(VMIN, 1); $termios.setCC(VTIME, 0); stdin.setTerminalAttributes(TCSADRAIN, $termios);
Table 4.104. Return Value for File::setTerminalAttributes()
Return Type | Description |
|---|---|
Always returns 0; if an error is encountered, an exception is raised. |
Table 4.105. Exceptions Thrown by File::setTerminalAttributes()
err | desc |
|---|---|
| The file is not open. |
| Error setting terminal attributes on the file descriptor. |
Returns a list of file status values for the current file (must be open).
If any errors occur, a FILE-STAT-ERROR exception is thrown.
See also static File::stat().
my int $mode = $file.stat()[2];Not available with PO_NO_FILESYSTEM
Table 4.107. Exceptions Thrown by File::stat()
err | desc |
|---|---|
|
|
Returns a hash of filesystem status values for the current file (must be open).
If any errors occur, a FILE-STATVFS-ERROR exception is thrown.
See also static File::statvfs().
my hash $h = $file.statvfs()Not available with PO_NO_FILESYSTEM
Table 4.108. Return Values for File::statvfs()
Return Type | Description | |
|---|---|---|
Returns a hash of filesystem status values current file; an exception is thrown if any errors occur. See also static File::statvfs(). See Filesystem Status Hash for a description of the hash returned by this function. |
Table 4.109. Exceptions Thrown by File::statvfs()
err | desc |
|---|---|
|
|
| This exception is thrown when the method is not available on the runtime platform; for maximum portability, check the constant |
Flushes the file's buffer to disk.
$f.sync();
Table 4.110. Return Value for File::sync()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes a formatted string to a file, where the first argument is a format string,and the second argument is the formatting argument list.
intFile::vprintf(string$fmt, any$args)
$f.vprintf("%5s\n", "hello");Table 4.111. Arguments for File::vprintf()
Argument | Description | |
|---|---|---|
| The format string, see String Formatting for a specification. | |
| This single argument or list of arguments will be used as the argument list or the format string. If a single argument is passed instead of a list, it will be used as the first argument as if a list were passed. |
Table 4.112. Return Value for File::vprintf()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes string or binary data to a file. String data will be converted to the file's character encoding if necessary before writing.
intFile::write(data$data)
$f.write($data);
Writes a 1-byte integer to the file.
intFile::writei1(softint$i = 0)
$f.writei1($val);
Table 4.117. Arguments for File::writei1()
Argument | Description |
|---|---|
| The integer to write; only the least-significant 8 bits will be written to the file. |
Table 4.118. Return Value for File::writei1()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes a 2-byte integer in big-endian format.
intFile::writei2(softint$i = 0)
$f.writei2($val);
Table 4.120. Arguments for File::writei2()
Argument | Description |
|---|---|
| The integer to write; writes a 2-byte integer in big-endian format. |
Table 4.121. Return Value for File::writei2()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes a 4-byte integer in big-endian format.
intFile::writei4(softint$i = 0)
$f.writei4($val);
Table 4.123. Arguments for File::writei4()
Argument | Description |
|---|---|
| The integer to write; writes a 4-byte integer in big-endian format. |
Table 4.124. Return Value for File::writei4()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes an 8-byte integer in big-endian format.
intFile::writei8(softint$i = 0)
$f.writei8($val);
Table 4.126. Arguments for File::writei8()
Argument | Description |
|---|---|
| The integer to write; writes an 8-byte integer in big-endian format. |
Table 4.127. Return Value for File::writei8()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes a 2-byte integer in little-endian format.
intFile::writei2LSB(softint$i = 0)
$f.writei2LSB($val);
Table 4.129. Arguments for File::writei2LSB()
Argument | Description |
|---|---|
| The integer to write; writes a 2-byte integer in little-endian format. |
Table 4.130. Return Value for File::writei2LSB()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes a 4-byte integer in little-endian format.
intFile::writei4LSB(softint$i = 0)
$f.writei4LSB($val);
Table 4.132. Arguments for File::writei4LSB()
Argument | Description |
|---|---|
| The integer to write; writes a 4-byte integer in little-endian format. |
Table 4.133. Return Value for File::writei4LSB()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
Writes an 8-byte integer to the file in little-endian (LSB) format.
intFile::writei8LSB(softint$i = 0)
$f.writei8LSB($val);
Table 4.135. Arguments for File::writei8LSB()
Argument | Description |
|---|---|
| The integer to write; writes an 8-byte integer in little-endian format. |
Table 4.136. Return Value for File::writei8LSB()
Return Type | Description |
|---|---|
Returns 0 for success, -1 for error. |
There are no comments yet