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
Core Library
Containers
Node-Related Classes
Rendering-Related Classes
Physics-Related Classes
Bounds-Related Classes
GUI-Related Classes
Controls-Related Classes
Pathfinding-Related Classes
Utility Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

FileSystem Class

Unigine virtual file system. This interface allows accessing external resources.

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

FileSystem Class

Members


const char * getPackageName (int num)

Returns a name of a given ZIP or UNG package.

Arguments

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

Return value

Name of the package.

const char * getPackageFileName (int num, const char * name)

Returns the full path with a file name relative to the package root directory given only the file name.

Arguments

  • int num - Number of the ZIP or UNG package.
  • const char * name - File name.

Return value

A path.

int removeFile (const char * name)

Removes file from the loading queue.

Arguments

  • const char * name - File name.

Return value

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

int loadPackage (const char * name, const char * extension = 0)

Loads an UNG or ZIP package into the file system. An archive can be located outside data directory if an absolute path is specified.
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

  • const char * name - Package name. It can be an absolute path or a path relative to data (data_path) directory, if it is inside of it.
  • const char * extension - ung or zip package extension.

Return value

1 if the package is loaded; otherwise, 0.

int setMTime (const char * name, long long time)

Sets the time of the file last modification.

Arguments

  • const char * name - File name.
  • long long time - Time stamp to set.

Return value

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

void addDirectory (const char * name)

Adds a directory to the file system.

Arguments

  • const char * name - Directory name.

int removeMesh (const char * name)

Removes a mesh from the loading queue.

Arguments

  • const char * name - Mesh name.

Return value

Returns 1 if the mesh is removed successfully; otherwise, 0.

void getFileNames (Vector< String > & names)

Fills the given vector with the list of unarchived files cached by the file system.

Arguments

  • Vector< String > & names - A vector where file names will be saved.

int isBlobFile (const char * name)

Checks if the given file is a blob file.

Arguments

  • const char * name - File name.

Return value

Returns 1 if the file is blobed; otherwise, 0.

int removeCacheFile (const char * 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.

Arguments

  • const char * name - File name.

Return value

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

int reloadPackage (const char * name)

Reloads package files.

Arguments

  • const char * name

Return value

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

int checkMesh (const char * name)

Checks whether the mesh was loaded to the queue or not.

Arguments

  • const char * name - Mesh name.

Return value

Returns 1 if the mesh is in the queue or already loaded to the file system; otherwise, 0.

Ptr<Image> getImage (const char * name)

Checks whether the image is placed to the loading queue and return it if it is placed.

Arguments

  • const char * name - Image name.

Return value

Loaded image smart pointer. If the image is not placed to the queue, NULL is retuned.

int getNumQueuedResources ()

Returns the number of queued file system resources waiting for the background loading. The return value represents the sum of the queued and the currently processed data, files, images and meshes.

Return value

Number of queued file system resources including the currently processed resources.

int forceImage (const char * name)

Loads an image immediately after calling the function. The image will be loaded right after the currently loading image (if any) is processed. All the other file system operations are suspended until the forced image is loaded.

Arguments

  • const char * name - Image name.

Return value

Returns 1 if the image is loaded successfully; otherwise, 0.

int 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 getNumFiles ()

Returns the number of files cached by the file system.

Return value

Number of cached files.

int getNumQueuedImages ()

Returns the number of queued images waiting for the background loading. The return value also includes the currently processed image.

Return value

Number of queued images including the currently processed image.

int findPackage (const char * name)

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

Arguments

  • const char * name - Package name. It can be an absolute path or a path relative to data (data_path) directory, if it is inside of it.

Return value

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

int getNumPackages ()

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

Return value

Number of packages.

float getTotalTime ()

Returns the total time (in milliseconds) of loading a file system resource.

Return value

The total time value, milliseconds.

int addBlobFile (const char * name)

Blobs a file in the memory.

Arguments

  • const char * name - File name.

Return value

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

const char * getFileName (const char * name)

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

Arguments

  • const char * name - File name or the partial path to it.

Return value

The path which is relative to the binary executable.

int loadMesh (const char * name, int group = 0, float weight = 0.0f)

Adds a mesh to the background loading queue (i.e. threaded mesh loading). Meshs with the identical groups and weights are loaded in the alphabetical order.

Arguments

  • const char * name - Mesh name.
  • int group - Group of the priority. The default is 0. Greater priority means faster loading.
  • float weight - Mesh priority. Greater weight means faster loading inside the same priority group. Default value is 0.

Return value

Returns 1 if the mesh is successfully appended to the queue; otherwise, 0.

void clearModifiers ()

Unregister all modifiers in the file system.

int removeImage (const char * name)

Removes an image from the loading queue.

Arguments

  • const char * name - Image name.

Return value

Returns 1 if the image is removed successfully; otherwise, 0.

int getNumQueuedData ()

Returns the number of queued file system data waiting for background loading. The return value also includes the currently processed data.

Return value

Number of queued file system data including the currently processed data.

int removePackage (const char * name)

Unloads an UNG or ZIP package from the file system. An archive can be located outside data directory if an absolute path is specified.

Arguments

  • const char * name - Package name. It can be an absolute path or a path relative to data (data_path) directory, if it is inside of it.

Return value

1 if the package is removed; otherwise, 0.

int loadFile (const char * name, int group = 0, float weight = 0.0f)

Adds a file to the background loading queue (i.e. threaded file loading). Files with identical priorities and weights are loaded in the alphabetical order.

Arguments

  • const char * name - File name.
  • int group - Group of the priority. The default is 0. Greater priority means faster loading.
  • float weight - File priority. Greater file priority means faster loading inside the same priority group. Default value is 0.

Return value

Returns 1 if the file is successfully appended to the queue; otherwise, 0.

int isKnownFile (const char * name)

Checks if the given file is known to the filesystem.

Arguments

  • const char * name - File name.

Return value

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

int loadImage (const char * name, int group = 0, float weight = 0.0f)

Adds an image to the background loading queue (i.e. threaded image loading). Images with the identical groups and weights are loaded in the alphabetical order.

Arguments

  • const char * name - Image name.
  • int group - Group of the priority. The default is 0. Greater priority means faster loading.
  • float weight - Image priority. Greater weight means faster loading inside the same priority group. Default value is 0.

Return value

Returns 1 if the image is successfully appended to the queue; otherwise, 0.

void getPackageFileNames (int num, Vector< String > & names)

Fills the given vector with the list of files in the specified ZIP or UNG package.

Arguments

  • int num - Number of the ZIP or UNG package.
  • Vector< String > & names - A vector where file names will be saved.

int forceFile (const char * name)

Loads the file immediately after calling this function. The file will be loaded right after the currently loading file (if any) is processed.

Arguments

  • const char * name - File name.

Return value

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

int forceMesh (const char * name)

Loads a mesh immediately after calling the function. The mesh will be loaded right after the currently loading mesh (if any) is processed. All the other file system operations are suspended until the forced mesh is loaded.

Arguments

  • const char * name - Mesh name.

Return value

Returns 1 if the mesh is loaded successfully; otherwise, 0.

int addKnownFile (const char * name)

Registers the regular file name as known and appends it into the map used for fast searching.

Arguments

  • const char * name - File name to register as known.

Return value

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

int checkImage (const char * name)

Checks whether the image was loaded to the queue or not.

Arguments

  • const char * name - Image name.

Return value

Returns 1 if the image is in the queue or already loaded to the file system; otherwise, 0.

int validateFile (const char * name)

Checks whether the file placed in the loading queue is loaded.

Arguments

  • const char * name - File name.

Return value

Returns 1 if the file is loaded; 0 if it is pending in the queue.

void removeModifier (const char * name)

Unregisters a given modifier in the file system.

Arguments

  • const char * name - Modifier name.

Ptr<Mesh> getMesh (const char * name)

Checks whether the mesh is placed to the loading queue.

Arguments

  • const char * name - Mesh name.

Return value

Loaded mesh smart pointer. If the mesh is not placed to the queue, NULL is retuned.

const char * getModifier (int num)

Returns the name of the given modifier.

Arguments

  • int num - ID number of the modifier.

Return value

Modifier name.

long long getMTime (const char * name)

Returns the time of the file last modification.

Arguments

  • const char * name - File name.

Return value

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

void addModifier (const char * name)

Registers a new modifier in the file system.

Arguments

  • const char * name - Modifier name.

int getNumModifiers ()

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

Return value

Number of modifiers.

int addCacheFile (const char * 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.

Arguments

  • const char * name - File name.

Return value

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

int getNumQueuedMeshes ()

Returns the number of queued meshes waiting for the background loading. The return value also includes the currently processed mesh.

Return value

Number of queued meshes including the currently processed mesh.

int isPackageFile (int num, const char * name)

Checks if the given file exists in the package.

Arguments

  • int num - Number of the ZIP or UNG package.
  • const char * name - File name.

Return value

1 if the file exists; otherwise, 0.

int isCacheFile (const char * name)

Checks if the given file is loaded into a cache.

Arguments

  • const char * name - File name.

Return value

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

int removeBlobFile (const char * name)

Removes a blob with a file from the memory. Blobing 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.

Arguments

  • const char * name - File name.

Return value

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

int isFile (const char * name)

Checks if a given file exists in the file system.

Arguments

  • const char * name - File name.

Return value

1 if the file is found; otherwise, 0.

int getNumQueuedFiles ()

Returns the number of queued files waiting for the background loading. The return value also includes the currently processed file.

Return value

Number of queued files including the currently processed file.

int checkFile (const char * name)

Checks whether the file was loaded to the queue.

Arguments

  • const char * name - File name.

Return value

Returns 1 if the file is in the queue or already loaded to the file system; otherwise, 0.
Last update: 2017-07-03
Build: ()