v1.2.0.1-beta1
|
The Dir
class provides static functions for directory operations, which are accessed in JS with the Dir.
qualifier. These are "atomic" operations such as getting information about a path, manipulating directories and so forth.
Public Member Functions | |
bool | mkpath (String &path) |
bool | mkdir (String &dirName) |
bool | rmpath (String &path) |
bool | rmdir (String &dirName, bool recurse=false) |
bool | exists (String &path) |
bool | isAbs (String &path) |
String | cwd () |
String | home () |
String | temp () |
String | root () |
String | separator () |
String | toNative (String &path) |
String | fromNative (String &path) |
String | clean (String &path) |
String | abs (String &path) |
String | normalize (String &path) |
bool mkpath | ( | String & | path | ) |
Creates the directory path path
. The function will create all parent directories necessary to create the directory. Returns true
if successful; otherwise returns false
. If the path already exists when this function is called, it will return true
.
bool mkdir | ( | String & | dirName | ) |
Creates a sub-directory called dirName
. Returns true
on success; otherwise returns false
. If the directory already exists when this function is called, it will return false
.
bool rmpath | ( | String & | path | ) |
Removes the directory path path
. The function will remove all parent directories in path
, provided that they are empty. This is the opposite of mkpath()
. Returns true
if successful; otherwise returns false
.
bool rmdir | ( | String & | dirName, |
bool | recurse = false |
||
) |
This function has two modes of operation:
recurse
= false
(default): Removes the directory specified by dirName
. The directory must be empty for rmdir()
to succeed.recurse
= true
: Removes the directory specified by dirName
, including all its contents. If a file or directory cannot be removed it keeps going and attempts to delete as many files and sub-directories as possible, then returns false
. If the directory was already removed, the method returns true
(expected result already reached). Returns true
if successful; otherwise returns false
, except as noted above. bool exists | ( | String & | path | ) |
Returns true
if path
exists in the file system, false
otherwise.
bool isAbs | ( | String & | path | ) |
Returns true
if path
is absolute (that is, from a root directory), false
otherwise (if it relative).
String cwd | ( | ) |
Returns the absolute path of the application's current directory. The current directory is the directory at which this application was started at by the parent process.
String home | ( | ) |
Returns the absolute path of the user's home directory. (Under Windows this function will return the directory of the current user's profile, eg C:/Users/Username
) Under non-Windows operating systems the HOME environment variable is used if it exists, otherwise the path returned by the rootPath().
String temp | ( | ) |
Returns the absolute canonical path of the system's temporary directory. On Unix/Linux systems this is the path in the TMPDIR environment variable or /tmp if TMPDIR is not defined. On Windows this is usually the path in the TEMP or TMP environment variable. The path returned by this method doesn't end with a directory separator unless it is the root directory (of a drive).
String root | ( | ) |
Returns the absolute path of the root directory. For Windows file systems this normally returns the boot drive letter (typically "c:/"). For Unix/Mac operating systems this returns "/".
String separator | ( | ) |
Returns the native directory separator: "/" under Unix and "\" under Windows. Note: You do not need to use this function to build file paths. You can always use "/" and it will be adjusted if needed.
Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
Returns path with directory separators normalized (that is, platform-native separators converted to "/") and redundant ones removed, and "."s and ".."s resolved (as far as possible). Symbolic links are kept.
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators.