This page has been translated automatically.
Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::File Class

Interface for data handling.

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

Unigine::File Class

Members


static Ptr< File > create ()

File constructor.

static Ptr< File > create (const StreamPtr & stream)

File constructor.

Arguments

  • const StreamPtr & stream - Stream smart pointer.

virtual int open (const char * name, const char * mode) const =0

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.

virtual int close () const =0

Closes a file for any operation.

Return value

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

virtual const char * getName () const =0

Returns a name of the opened file.

Return value

File name.

virtual size_t getSize () const =0

Returns the size of the opened file in bytes.

Return value

File size in bytes.

virtual int eof () const =0

Returns a value indicating if the file end is reached.

Return value

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

virtual int getc () const =0

Returns the next character from the opened file.

Return value

Single character read from the opened file.

virtual int seekSet (size_t offset) const =0

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.

virtual int seekEnd (size_t offset) const =0

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.

virtual int seekCur (size_t offset) const =0

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.

virtual size_t tell () const =0

Returns the current offset of the file position indicator.

Return value

Returns the current offset in bytes.

virtual int flush () const =0

Forces to write of all buffered data to the file.

Return value

Returns 1 if the data is written successfully; otherwise, 0.
Last update: 03.07.2017
Build: ()