This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related 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.

engine.filesystem Functions

FileSystem Class

Members


int engine.filesystem.isBlobFile(string name)

Checks if the given file is loaded to a blob. A path to the file can be both absolute or relative to the data directory.

Arguments

  • string name - Absolute or relative path to the file (including its name).

Return value

1 if the file is loaded to a blob successfully; otherwise, 0.

int engine.filesystem.isCacheFile(string name)

Checks if the given file is loaded into cache. A path to the file should be relative to the data folder.

Arguments

  • string name - Relative path to the file (including its name).

Return value

1 if the file is added into cache; otherwise, 0.

int engine.filesystem.isFile(string name, int strict = 0)

Checks if a file with the given name exists in the file system.

Arguments

  • string name - Absolute or relative path to the file (including its name).
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if the file exists; otherwise, 0.

string engine.filesystem.getFileName(string name, int strict = 0)

Returns the relative path to the file by the given partial one. The path will be relative to the binary executable.

Arguments

  • string name - File name or the partial path to it.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

Path which is relative to the binary executable.

string engine.filesystem.getFileName(UGUID guid, int strict = 0)

Returns the relative path to the file by the given file GUID. The path will be relative to the binary executable.

Arguments

  • UGUID guid - File GUID.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

Path which is relative to the binary executable.

int engine.filesystem.isKnownFile(string name, int strict = 0)

Checks if the given file is known to the file system. A path to the file can be both relative or absolute to the data directory.

Arguments

  • string name - An absolute or relative path to the file (including its name).
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if the file is known to the file system; otherwise, 0.

string engine.filesystem.getModifier(int num)

Returns the name of the given modifier.

Arguments

  • int num - ID number of the modifier.

Return value

Modifier name.

int engine.filesystem.setMTime(string name, long time, int strict = 0)

Sets the time of the file last modification.

Arguments

  • string name - File name.
  • long time - Time stamp to set.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if the time stamp is set successfully; otherwise, 0.

long engine.filesystem.getMTime(string name, int strict = 0)

Returns the time of the file last modification.

Arguments

  • string name - File name.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

Time of the last modification. If there is no file with such name, -1 will be returned.

int engine.filesystem.getNumFiles()

Returns the number of files cached by the file system.

Return value

Number of cached files.

int engine.filesystem.getNumModifiers()

Returns the total number of file modifiers registered in the file system.

Return value

Number of modifiers.

int engine.filesystem.getNumPackageFiles(int num)

Returns the number of files inside of a given ZIP or UNG package.

Arguments

  • int num - Number of the ZIP or UNG package.

Return value

Number of files inside a package.

int engine.filesystem.getNumPackages()

Returns the number of ZIP and UNG packages inside the data directory.

Return value

Number of packages.

int engine.filesystem.isPackageFile(int num, string name, int strict = 0)

Checks if a file with a given name exists in the specified package.

Arguments

  • int num - Number of the ZIP or UNG package in the array of the loaded packages.
  • string name - File name.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if the file exists; otherwise, 0.

string engine.filesystem.getPackageFileName(int num, string name, int strict = 0)

Returns the path to the given file relative to the package root directory. The path includes the name of the given file.
Source code (UnigineScript)
log.message("A path to the file inside the package: %s\n",engine.filesystem.getPackageFilesystem(0,"material_ball.mesh"));
Output
A path to the file inside the package: meshes/material_ball.mesh

Arguments

  • int num - Number of the ZIP or UNG package in the array of the loaded packages.
  • string name - File name.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

A path to the file of the package.

string engine.filesystem.getPackageName(int num)

Returns an absolute path (including a name) to a given ZIP or UNG package.
Source code (UnigineScript)
log.message("A path to a package: %s\n",engine.filesystem.getPackageName(0));
Output
A path to a package: D:/unigine_projects/unigine_project/data/core.ung

Arguments

  • int num - Number of the ZIP or UNG package in the array of the loaded packages.

Return value

An absolute path to the package (including its name).

int engine.filesystem.addBlobFile(string name)

Adds a file into a blob. It can be used for files that are frequently modified in run-time (for example, images). After such file is loaded from a disk and written into a blob in the memory, its modifications can be saved fast into this blob. A path to the file can be both absolute or relative to the data directory.

Arguments

  • string name - Absolute or relative path to the file (including its name).

Return value

1 if the file is successfully added into a blob; otherwise, 0.

int engine.filesystem.addBlobFile(string name, UGUID guid)

Adds a file with the given GUID into a blob. It can be used for files that are frequently modified in run-time (for example, images). After such file is loaded from a disk and written into a blob in the memory, its modifications can be saved fast into this blob. A path to the file can be both absolute or relative to the data directory.

Arguments

  • string name - Absolute or relative path to the file (including its name).
  • UGUID guid - File GUID.

Return value

1 if the file is successfully added into a blob; otherwise, 0.

int engine.filesystem.addCacheFile(string name)

Caches a file in the memory. It can be used for files that are accessed multiple times in run-time (for example, textures are read two times in a row). Such files are loaded into the memory for faster reading. A path to the file should be relative to the data folder.

Arguments

  • string name - Relative path to the file (including its name) to add to cache.

Return value

1 if the file is successfully added to cache; otherwise, 0.

int engine.filesystem.addCacheFile(string name, UGUID guid)

Caches a file in the memory with the given GUID. It can be used for files that are accessed multiple times in run-time (for example, textures are read two times in a row). Such files are loaded into the memory for faster reading. A path to the file should be relative to the data folder.

Arguments

  • string name - Relative path to the file (including its name) to add to cache.
  • UGUID guid - File GUID.

Return value

1 if the file is successfully added to cache; otherwise, 0.

void engine.filesystem.addDirectory(string name)

Adds an external directory to the file system.

Arguments

  • string name - Absolute path to the directory (including its name).

int engine.filesystem.addKnownFile(string name, int strict = 0)

Registers the regular file name as known and appends it to the map used for fast searching. A path to the file can be both relative or absolute to the data directory.

Arguments

  • string name - Absolute or relative path to the file to register its name as known.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if the file name is appended successfully; otherwise, 0.

int engine.filesystem.addKnownFile(string name, UGUID guid, int strict = 0)

Registers the regular file name as known with the given GUID and appends it to the map used for fast searching. A path to the file can be both relative or absolute to the data directory.

Arguments

  • string name - Absolute or relative path to the file to register its name as known.
  • UGUID guid - File GUID.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if the file name is appended successfully; otherwise, 0.

void engine.filesystem.addModifier(string name)

Registers a new modifier in the file system.

Arguments

  • string name - Modifier name.

void engine.filesystem.clearModifiers()

Unregister all modifiers in the file system.

int engine.filesystem.findPackage(string name)

Checks if an UNG or ZIP package has been added into the file system.

Arguments

  • string name - An absolute path to the package (including its name).

Return value

Number of the ZIP or UNG package if it is found; otherwise, -1.

int engine.filesystem.loadPackage(string name, string extension = 0)

Loads an UNG or ZIP package into the file system. An archive can be located outside data directory ( an absolute path should be specified in this case).
Notice
UNG packages without password protection can be loaded even if the engine has built-in password for the file system packages. For example, it is possible to load both the core.ung package without a password and the my_assets.ung package protected with a password.

Arguments

  • string name - Package name. It can be an absolute path or a path relative to data directory, if it is inside of it.
  • string extension - ung or zip package extension.

Return value

1 if the package is loaded; otherwise, 0.

int engine.filesystem.reloadPackage(string name)

Reloads package files.

Arguments

  • string name

Return value

Returns 1 if the package is reloaded successfully; otherwise, 0.

int engine.filesystem.removeBlobFile(string name)

Arguments

  • string name - An absolute or relative path to the file (including its name).

Return value

int engine.filesystem.removeCacheFile(string name)

Removes a cached file from the memory. Caching can be used for files that are accessed multiple times in run-time (for example, textures are read two times in a row). Such files are loaded into the memory for faster reading. A path to the file should be relative to the data folder.

Arguments

  • string name - A relative path to the file (including its name) to be removed from a cache.

Return value

1 if the file is successfully removed from cache; otherwise, 0.

void engine.filesystem.removeModifier(string name)

Unregisters a given modifier in the file system.

Arguments

  • string name - Modifier name.

int engine.filesystem.removePackage(string name)

Unloads an UNG or ZIP package from the file system.

Arguments

  • string name - An absolute path to the package (including its name).

Return value

1 if the package is removed; otherwise, 0.

int engine.filesystem.setGUID(string name, UGUID guid, int strict = 0)

Sets the specified GUID for the given file.

Arguments

  • string name - File path.
  • UGUID guid - GUID to be set for the file.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if the GUID is set successfully; otherwise, 0.

UGUID engine.filesystem.getGUID(string name, int strict = 0)

Returns the GUID (if it exists) for the given file.

Arguments

  • string name - File path.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

File GUID if it exists, or an empty GUID, otherwise.

int engine.filesystem.isGUID(string name)

Returns a value indicating if the given input string is a GUID.

Arguments

  • string name - Input string.

Return value

1 if the given input string is a GUID; otherwise, 0.

int engine.filesystem.saveGUIDs(string name)

Saves all file system GUIDs to the specified file.

Arguments

  • string name - Path to the file, where file system GUIDs are to be stored.

Return value

1 if all file system GUIDs are saved successfully; otherwise, 0.

int engine.filesystem.loadGUIDs(string name, int strict = 0)

Loads file system GUIDs from the specified file.

Arguments

  • string name - Path to the file, where file system GUIDs are stored.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

1 if file system GUIDs are loaded successfully; otherwise, 0.

void engine.filesystem.clearGUIDs()

Clears all file system GUIDs.

string engine.filesystem.getRelativeFileName(string name, int strict = 0)

Returns a path to the given file which is relative to the data folder.

Arguments

  • string name - File name or the partial path to it.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

Path to the file relative to the data folder.

string engine.filesystem.getRelativeFileName(UGUID guid, int strict = 0)

Returns a path to the given file which is relative to the data folder.

Arguments

  • UGUID guid - File GUID.
  • int strict - Strict flag. When the flag is set to 1, the filesystem will disable checks for any other relative paths, that could contain specified path, and perform exact search instead.

Return value

Path to the file relative to the data folder.
Last update: 2017-12-21
Build: ()