This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
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
Materials and Shaders
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.

Dir 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.

This class allows the user to retrieve various directory attributes, including file specific information. Also, the class provides the ability to copy files to different directories.

Notice
Dir class cannot resolve a relative path, so a request to (see the FileSystem::getAbsolutePath()() method) is required.

Dir Class

Members


static Dir ( ) #

Default constructor.

static Dir ( string name ) #

Constructor. Creates a new directory instance.

Arguments

  • string name - Directory path to open.

getDirName ( int num ) #

Returns name of the directory with given index.

Arguments

  • int num - Directory index.

Return value

Name of the directory with num index.

getFileMTime ( int num ) #

Returns the time of the file last modification.

Arguments

  • int num - File index.

Return value

Time of the last modification.

getFileName ( int num ) #

Returns name of the file with given index.

Arguments

  • int num - File index.

Return value

Name of the file with num index.

getFileSize ( int num ) #

Returns the size of the file with the given index.

Arguments

  • int num - File index.

Return value

File size.

long getFileSize ( string path ) #

Returns the size of the specified file.

Arguments

  • string path - Path to an existing file to retrieve the size for.

Return value

File size in bytes.

int setMTime ( string path, long time ) #

Sets the time of the last directory modification.

Arguments

  • string path - Directory name.
  • long time - Time of the last modification.

Return value

1 if the time of the last directory modification was set successfully; otherwise, 0.

long getMTime ( string path ) #

Returns the time of the last directory modification.

Arguments

  • string path - Directory name.

Return value

Time of the last modification.

getName ( ) #

Returns the name of the current directory.

Return value

Directory name.

int getNumDirs ( ) #

Returns number of nested directories.

Return value

Number of directories.

int getNumFiles ( ) #

Returns number of files inside the directory.

Return value

Number of files.

int isFile ( string path ) #

Returns a value indicating if the specified file path exists.

Arguments

  • string path - File path to be checked.

Return value

1 if the specified file path exists; otherwise, 0.

int isOpened ( ) #

Checks whether the directory is opened.

Return value

1 if the directory is opened; otherwise, 0.

getSize ( ) #

Returns the size of the current directory.

Return value

Directory size.

bool close ( ) #

Closes the directory descriptor.

Return value

bool open ( ) #

Opens the directory. Always close the directory descriptor via (see the close()() method) before leaving the scope:

Arguments

    Return value

    Directory descriptor.

    int isAbsolute ( string path ) #

    Returns a value indicating if the specified directory path is an absolute one.

    Arguments

    • string path - Directory path.

    Return value

    1 if the specified directory path is an absolute one; otherwise, 0.

    int copy ( string path, string new_name ) #

    Copies the specified file to a new destination path.

    Arguments

    • string path - Source file path.
    • string new_name - Destination file path.

    Return value

    1 if the specified file was successfully copied; otherwise, 0.

    int isDir ( string path ) #

    Returns a value indicating if the specified directory exists.

    Arguments

    • string path - Directory path to be checked.

    Return value

    1 if the specified directory exists; otherwise, 0.

    string getHomeDir ( ) #

    Returns a path to the home directory.

    Return value

    Path to the current working directory.

    string getCurrentDir ( ) #

    Returns a path to the current working directory.

    Return value

    Path to the current working directory.

    int chdir ( string path ) #

    Changes the current working directory to the given path.

    Arguments

    • string path - New path to which the current working directory is to be chahged.

    Return value

    1 if the current working directory is changed successfully; otherwise, 0.

    int mkdir ( string path ) #

    Creates a directory named path.

    Arguments

    • string path - Path to a new directory to be created.

    Return value

    1 if the specified directory is created successfully; otherwise, 0.

    int mkdir ( string path, int recursion ) #

    Creates a directory named path.

    Arguments

    • string path - Path to a new directory to be created.
    • int recursion - Use 1 to create non-existent directories recursively; otherwise, 0.

    Return value

    1 if the specified directory is created successfully; otherwise, 0.

    int rmdir ( string path ) #

    Removes the specified directory path. It works only when the directory is empty and is neither the current working directory or the home directory.

    Arguments

    • string path - Path of the directory to be removed.

    int rmdir ( string path, int recursion ) #

    Removes the specified directory path. It works only when the directory is empty and is neither the current working directory or the home directory.

    Arguments

    • string path - Path of the directory to be removed.
    • int recursion - Use 1 to remove directories recursively; otherwise, 0.

    Return value

    1 if the specified directory path is removed successfully; otherwise, 0.

    int remove ( string path ) #

    Removes the specified file.

    Arguments

    • string path - Path to a file to be removed.

    Return value

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

    int rename ( string path, string new_name ) #

    Renames the specified file path to new_name.

    Arguments

    • string path - Path to a file to be renamed.
    • string new_name - New path to a file.

    Return value

    1 if the specified file is renamed successfully; otherwise, 0.

    int chmod ( string path, int mode ) #

    Changes the permission setting of the specified file. The permission setting controls the read and write access to the file.

    Arguments

    • string path - Path to an existing file to change the permission setting for.
    • int mode - New permission setting for the specified file (1 - RW, 0 - RO).

    Return value

    1 if the permission setting of the specified file is successfully changed; otherwise, 0.

    int getmod ( string path ) #

    Returns the permission setting of the specified file. The permission setting controls the read and write access to the file.

    Arguments

    • string path - Path to an existing file to retrieve the permission setting for.

    Return value

    Permission setting for the specified file (1 - RW, 0 - RO); otherwise, -1 - if the filename or path could not be found.

    int setAttribute ( string path, int attribute ) #

    Sets a new file system attribute for the specified file or directory.

    Arguments

    • string path - Path to a file or directory for which a new attribute is to be set.
    • int attribute - New file or directory attribute to be set. One of the ATTRIBUTE_* values.

    Return value

    1 if the specified file attribute is successfully set for the specified file/directory path; otherwise, 0.

    int getAttribute ( string path ) #

    Returns a file system attribute for a specified file or directory.

    Arguments

    • string path - Path to a file or directory for which an attribute is to be retrieved.

    Return value

    File or directory attribute. One of the ATTRIBUTE_* values.
    Last update: 2022-09-01
    Build: ()