This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm (Experimental)
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine.Dir Class

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.

Usage Example

Here is an example of how to print out names of all nested directories in the specified directory:

Source code (C#)
// create a descriptor for the specified directory and open it
Unigine.Dir dir = new Unigine.Dir();
dir.Open("path"); //write your path string

// loop through all nested directories and print their names
int numDirs = dir.GetNumDirs();
for (int i = 0; i < numDirs; ++i)
{
string dirName = dir.GetDirName(i);
Unigine.Log.Message("Dir name " + dirName + "\n");
}

// close the directory descriptor
dir.Close();

Dir Class

Properties

bool IsOpened#

Checks whether the directory is opened.

Members


static Dir ( ) #

Default constructor.

static Dir ( string name ) #

Constructor. Creates a new directory instance.

Arguments

  • string name - Directory path to open.

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

long GetFileMTime ( int num ) #

Returns the time of the file last modification.

Arguments

  • int num - File index.

Return value

Time of the last modification.

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

uint GetFileSize ( int num ) #

Returns the size of the file with the given index.

Arguments

  • int num - File index.

Return value

File size.

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.

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

bool IsFile ( string path ) #

Returns a value indicating if the specified file path exists.

Arguments

  • string path - File path to be checked.

Return value

true if the specified file path exists; otherwise, false.

uint GetSize ( ) #

Returns the size of the current directory.

Return value

Directory size.

bool Close ( ) #

Closes the directory descriptor.

Return value

true if the directory descriptor is closed successfully; otherwise, false.

bool Open ( string name ) #

Opens the directory.

Arguments

  • string name - Directory path.

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.

bool IsDir ( string path ) #

Returns a value indicating if the specified directory exists.

Arguments

  • string path - Directory path to be checked.

Return value

true if the specified directory exists; otherwise, false.

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, bool recursion ) #

Creates a directory named path.

Arguments

  • string path - Path to a new directory to be created.
  • bool recursion - Use true to create non-existent directories recursively; otherwise, false.

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, bool 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.
  • bool recursion - Use true to remove directories recursively; otherwise, false.

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: 2020-11-24
Build: ()