Unigine.File Class
Inherits: | Stream |
File Class
Members
static File ( ) #
Default constructor.static File ( string name, string mode ) #
Constructor.Arguments
- string name - File name.
- string mode - Access mode (see open()).
int Getc ( ) #
Reads the next character from the file.Return value
Single character read from the opened file.string GetName ( ) #
Returns a name of the opened file.Return value
File name.uint GetSize ( ) #
Returns the size of the opened file in bytes.Return value
File size in bytes.bool Close ( ) #
Closes a file for any operation.Return value
Returns 1 if the file is closed successfully; otherwise, 0.int Eof ( ) #
Tests for end-of-file on a file descriptor.Return value
1 if it is the end of file; 0 otherwise.int Flush ( ) #
Forces to write of all buffered data to the file.Return value
1 if the data is written successfully; otherwise, 0.bool Open ( string name, string mode ) #
Opens a file with a given access mode: rb to open file for reading; wb to create a new file.- r - Open for reading only. The stream is positioned at the beginning of the file.
- r+ - Open for reading and writing. The stream is positioned at the beginning of the file.
- w - Truncate file to zero length or create file for writing. The stream is positioned at the beginning of the file.
- w+ - Open for reading and writing. The file is created if it does not exist, otherwise it is truncated to zero length. The stream is positioned at the beginning of the file.
- a - Open for appending (writing at end of file). The file is created if it does not exist. The stream is positioned at the end of the file.
- a+ - Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading is at the beginning of the file, but output is always appended to the end of the file.
- b - For binary files. Otherwise, the file is deemed a text file, and Windows replaces \n with \n\r in text files.
Arguments
- string name - Name of the file to open.
- string mode - Access mode.
Return value
Returns 1 if the file is opened (or created, if the wb access mode is specified) successfully; otherwise, 0.int SeekCur ( uint offset ) #
Sets an offset of the file position indicator relative to its current position.Arguments
- uint offset - Offset of the file position indicator from the current position, in bytes.
Return value
Returns 1 if the file position indicator offset is set successfully; otherwise, 0.int SeekEnd ( uint offset ) #
Sets an offset of the file position indicator relative to the end of the file.Arguments
- uint offset - File position indicator offset from the end of the file in bytes.
Return value
Returns 1 if the file position indicator offset is set successfully; otherwise, 0.int SeekSet ( uint offset ) #
Sets an offset of the file position indicator relatively to the start of the file.Arguments
- uint offset - Offset of the file position indicator from the start of the file, in bytes.
Return value
1 if the offset has been set successfully; otherwise, 0.uint Tell ( ) #
Returns the current offset of the file position indicator.Return value
Offset in bytes from the beginning of the file.Last update:
2020-04-10
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)