Namespaces | Functions
basis::os Namespace Reference

Namespaces

 path
 

Functions

bool emptydir (const std::string &path)
 Remove files and directories from directory. More...
 
std::string exedir ()
 Get canonical path to directory containing executable file. More...
 
std::string exename ()
 Get name of executable. More...
 
std::string exepath ()
 Get canonical path of executable file. More...
 
std::string getcwd ()
 Get absolute path of the (current) working directory. More...
 
bool makedirs (const std::string &path)
 Make directory including parent directories if required. More...
 
bool mkdir (const std::string &path)
 Make directory. More...
 
std::string readlink (const std::string &path)
 Read value of symbolic link. More...
 
bool rmdir (const std::string &path)
 Remove empty directory. More...
 
bool rmtree (const std::string &path)
 Remove whole directory tree. More...
 

Function Documentation

§ emptydir()

bool basis::os::emptydir ( const std::string &  path)

Remove files and directories from directory.

Parameters
pathPath of the directory.
Returns
Whether the directory was cleared successfully, i.e., leaving the directory path empty.

Definition at line 238 of file os.cxx.

§ exedir()

string basis::os::exedir ( )

Get canonical path to directory containing executable file.

Returns
Canonical path to directory containing executable file.
See also
exepath()
exename()

Definition at line 140 of file os.cxx.

§ exename()

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.
See also
exepath()
exedir()

Definition at line 127 of file os.cxx.

§ exepath()

string basis::os::exepath ( )

Get canonical path of executable file.

Returns
Canonical path of executable file or empty string on error.
See also
exedir()
exename()

Definition at line 63 of file os.cxx.

§ getcwd()

string basis::os::getcwd ( )

Get absolute path of the (current) working directory.

Returns
Absolute path of working directory or empty string on error.

Definition at line 47 of file os.cxx.

§ makedirs()

bool basis::os::makedirs ( const std::string &  path)

Make directory including parent directories if required.

Parameters
pathPath 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.

Definition at line 205 of file os.cxx.

§ mkdir()

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
pathPath 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()

Definition at line 199 of file os.cxx.

§ readlink()

string basis::os::readlink ( const std::string &  path)

Read value of symbolic link.

Parameters
[in]pathPath 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()

Definition at line 147 of file os.cxx.

§ rmdir()

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
pathPath of the directory.
Returns
Whether the directory was removed successfully.
See also
rmtree()

Definition at line 226 of file os.cxx.

§ rmtree()

bool basis::os::rmtree ( const std::string &  path)

Remove whole directory tree.

Parameters
pathPath of the directory.
Returns
Whether the directory was removed successfully.

Definition at line 232 of file os.cxx.