basis::os Namespace Reference
Namespaces | |
namespace | path |
Functions | |
bool | emptydir (const std::string &path) |
Remove files and directories from directory. | |
std::string | exedir () |
Get canonical path of directory containing executable file. | |
std::string | exename () |
Get name of executable. | |
std::string | exepath () |
Get canonical path of executable file. | |
std::string | getcwd () |
Get absolute path of the (current) working directory. | |
bool | makedirs (const std::string &path) |
Make directory including parent directories if required. | |
bool | mkdir (const std::string &path) |
Make directory. | |
std::string | readlink (const std::string &path) |
Read value of symbolic link. | |
bool | rmdir (const std::string &path) |
Remove empty directory. | |
bool | rmtree (const std::string &path) |
Remove whole directory tree. |
Function Documentation
bool basis::os::emptydir | ( | const std::string & | path | ) |
string basis::os::exedir | ( | ) |
string basis::os::exename | ( | ) |
Get name of executable.
- Note:
- The name of the executable may or may not include the file name extension depending on the executable type and operating system. Hence, this function is neither an equivalent to path::basename(exepath()) nor path::filename(exepath()). In particular, on Windows, the .exe and .com extension is not included in the returned executable name.
- Returns:
- Name of the executable derived from the executable's file path or empty string on error.
string basis::os::exepath | ( | ) |
string basis::os::getcwd | ( | ) |
bool basis::os::makedirs | ( | const std::string & | path | ) |
Make directory including parent directories if required.
- Parameters:
-
path Path of the directory.
- Returns:
- Whether the directory was created successfully. Note that on Posix, the created directories will have mode 0755. On Windows, the default security descriptor is passed on to the CreateDirectory() function.
bool basis::os::mkdir | ( | const std::string & | path | ) |
Make directory.
- Note:
- The parent directory must exist already. See makedirs() for a function that also creates the parent directories if none-existent.
- Parameters:
-
path Path of the directory.
- Returns:
- Whether the directory was created successfully. Note that on Posix, the created directory will have mode 0755. On Windows, the default security descriptor is passed on to the CreateDirectory() function.
- See also:
- makedirs()
string basis::os::readlink | ( | const std::string & | path | ) |
Read value of symbolic link.
- Parameters:
-
[in] path Path of symbolic link.
- Returns:
- Value of symbolic link. Can be relative or absolute path. If the link could not be read, an empty string is returned. Note that on Windows, this function always returns an empty string.
- See also:
- realpath()
bool basis::os::rmdir | ( | const std::string & | path | ) |
Remove empty directory.
This function removes an empty directory. If the directory is not empty, it will fail. See rmtree() for a function that also removes the files and recursively the directories within the specified directory.
- Parameters:
-
path Path of the directory.
- Returns:
- Whether the directory was removed successfully.
- See also:
- rmtree()