This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
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

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
Inherits from: Stream

This class allows you to write and read data into files. Files are stored locally (unlike Buffer which exists only in the memory).

See Also#

  • C++ API sample located in the folder <UnigineSDK>/source/samples/Api/Systems/File

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()).

getName ( ) #

Returns a name of the opened file.

Return value

File name.

getSize ( ) #

Returns the size of the opened file in bytes.

Return value

File size in bytes.

close ( ) #

Flushes the stream (writing any buffered output data by flush()) and close the file descriptor.

Return value

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.

open ( ) #

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

    Return value

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

    int seekCur ( ) #

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

    Arguments

      Return value

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

      int seekEnd ( ) #

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

      Arguments

        Return value

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

        int seekSet ( ) #

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

        Arguments

          Return value

          1 if the offset has been set successfully; otherwise, 0.

          tell ( ) #

          Returns the current offset of the file position indicator.

          Return value

          Offset in bytes from the beginning of the file.
          Last update: 2021-12-13
          Build: ()