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:
// 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
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 name, long value ) #
Sets the time of the last directory modification.Arguments
- string name - Directory name.
- long value - Time of the last modification.
Return value
1 if the time of the last directory modification was set successfully; otherwise, 0.long GetMTime ( string name ) #
Returns the time of the last directory modification.Arguments
- string name - 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.int IsFile ( string name ) #
Returns a value indicating if the specified file path exists.Arguments
- string name - 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.uint GetSize ( ) #
Returns the size of the current directory.Return value
Directory size.int Close ( ) #
Closes the directory descriptor.Return value
1 if the directory descriptor is closed successfully; otherwise, 0.int Open ( string name ) #
Opens the directory.Arguments
- string name - Directory path.
Return value
Directory descriptor.int IsAbsolute ( string name ) #
Returns a value indicating if the specified directory path is an absolute one.Arguments
- string name - Directory path.
Return value
1 if the specified directory path is an absolute one; otherwise, 0.int Copy ( string name, string new_name ) #
Copies the specified file to a new destination path.Arguments
- string name - Source file path.
- string new_name - Destination file path.
Return value
1 if the specified file was successfully copied; otherwise, 0.int IsDir ( string name ) #
Returns a value indicating if the specified directory exists.Arguments
- string name - Directory path to be checked.
Return value
1 if the specified directory exists; otherwise, 0.Last update:
2020-08-25
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)