Unigine::Dir Class
Header: | #include <UnigineDir.h> |
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::DirPtr dir = Unigine::Dir::create();
dir->open("path"); //write your path string
// loop through all nested directories and print their names
int num_dirs = dir->getNumDirs();
for (int i = 0; i < num_dirs; ++i)
{
const char* dirname = dir->getDirName(i);
Unigine::Log::message("Dir name %s\n", dirname);
}
// close the directory descriptor
dir->close();
Dir Class
Members
static DirPtr create ( ) #
Default constructor.static DirPtr create ( const char * name ) #
Constructor. Creates a new directory instance.Arguments
- const char * name - Directory path to open.
const char * 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 long getFileMTime ( int num ) #
Returns the time of the file last modification.Arguments
- int num - File index.
Return value
Time of the last modification.const char * 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.size_t getFileSize ( int num ) #
Returns the size of the file with the given index.Arguments
- int num - File index.
Return value
File size.int setMTime ( const char * name, long long value ) #
Sets the time of the last directory modification.Arguments
- const char * name - Directory name.
- long long value - Time of the last modification.
Return value
1 if the time of the last directory modification was set successfully; otherwise, 0.long long getMTime ( const char * name ) #
Returns the time of the last directory modification.Arguments
- const char * name - Directory name.
Return value
Time of the last modification.const char * 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 ( const char * name ) #
Returns a value indicating if the specified file path exists.Arguments
- const char * 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.size_t 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 ( const char * name ) #
Opens the directory.Arguments
- const char * name - Directory path.
Return value
Directory descriptor.int isAbsolute ( const char * name ) #
Returns a value indicating if the specified directory path is an absolute one.Arguments
- const char * name - Directory path.
Return value
1 if the specified directory path is an absolute one; otherwise, 0.int copy ( const char * name, const char * new_name ) #
Copies the specified file to a new destination path.Arguments
- const char * name - Source file path.
- const char * new_name - Destination file path.
Return value
1 if the specified file was successfully copied; otherwise, 0.int isDir ( const char * name ) #
Returns a value indicating if the specified directory exists.Arguments
- const char * 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)