This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Engine Classes
Node-Related Classes
Rendering-Related Classes
Physics-Related Classes
Bounds-Related Classes
GUI-Related Classes
Controls-Related Classes
Pathfinding-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

File Class

Interface for data handling.

To use this class, include the UnigineFile.h file.

File Class

Members


File ()

Default constructor.

File (const char * name, const char * mode)

Constructor.

Arguments

  • const char * name - File name.
  • const char * mode - Access mode (see open()).

size_t tell ()

Returns the current offset of the file position indicator.

Return value

Returns the current offset in bytes.

int seekEnd (size_t offset)

Sets an offset of the file position indicator relative to the end of the file.

Arguments

  • size_t 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 eof ()

Returns a value indicating if the file end is reached.

Return value

Returns 1 if the file end is reached; otherwise, 0.

size_t getSize ()

Returns the size of the opened file in bytes.

Return value

File size in bytes.

int open (const char * name, const char * 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. The mode string can also include the letter b either as a last character or as a character between the characters in any of the two-character strings described above. It shall have no effect, but is allowed for ISO C standard conformance.

Arguments

  • const char * name - Name of the file to open.
  • const char * mode - Access mode.

Return value

Returns 1 if the file is opened (or created, if the wb access mode is specified) successfully; otherwise, 0.

const char * getName ()

Returns a name of the opened file.

Return value

File name.

int seekCur (size_t offset)

Sets an offset of the file position indicator relative to its current position.

Arguments

  • size_t offset - File position indicator offset from the current position in bytes.

Return value

Returns 1 if the file position indicator offset is set successfully; otherwise, 0.

int seekSet (size_t offset)

Sets an offset of the file position indicator relative to the start of the file.

Arguments

  • size_t offset - File position indicator offset from the beginning of the file in bytes.

Return value

Returns 1 if the file position indicator offset is set successfully; otherwise, 0.

int getc ()

Returns the next character from the opened file.

Return value

Single character read from the opened file.

int flush ()

Forces to write of all buffered data to the file.

Return value

Returns 1 if the data is written successfully; otherwise, 0.

int close ()

Closes a file for any operation.

Return value

Returns 1 if the file is closed successfully; otherwise, 0.

Ptr<File> create (const Ptr<Stream> & stream)

File constructor.

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.

Return value

Last update: 2017-07-03
Build: ()