coan
6.0.1
A C/C++ Configuration Analyzer
|
Namespace fs
encloses filesystem operations.
More...
Typedefs | |
using | obj_type_t = unsigned |
Abstract type of filesystem object types. | |
using | permissions = int |
Type of file permissions mask. | |
Enumerations | |
enum | { OBJ_NONE, OBJ_SLINK = 1, OBJ_FILE = 2, OBJ_DIR = 4 } |
Symbolic constants denoting filesystem objects. More... | |
Functions | |
bool | is_file (obj_type_t type) |
Say whether an object type is a file. More... | |
bool | is_dir (obj_type_t type) |
Say whether an object type is a directory. More... | |
bool | is_slink (obj_type_t type) |
Say whether an object type is a symbolic link. More... | |
obj_type_t | obj_type (std::string const &name) |
Get the type of the object putatively designated by a filename. | |
std::string | real_path (std::string const &relname) |
Get the absolute real pathname of a file or directory name. More... | |
std::string | abs_path (std::string const &filename) |
Get the absolute pathname for a filename. More... | |
bool | is_absolute (std::string pathname) |
Say whether a filename is absolute or relative. | |
std::string | cwd () |
Get the absolute real pathname of the current working directory. | |
std::string | tempname (std::string const &format) |
Create a tempory filename from a template. More... | |
void | make_dir (std::string const &abs_path, bool recursive=true) |
Create a directory given an absolute path name. More... | |
permissions | get_permissions (std::string const &filename) |
int | set_permissions (std::string const &filename, permissions p) |
Namespace fs
encloses filesystem operations.
anonymous enum |
std::string fs::abs_path | ( | std::string const & | filename | ) |
Get the absolute pathname for a filename.
filename | An absolute or relative pathname that need not refer to any existing object. |
filename
refers to an existing object the returned string is as per real_path
. Otherwise, if filename
is an absolute path it is returned unchanged. Otherwise it is returned prefixed with the current working directory. permissions fs::get_permissions | ( | std::string const & | filename | ) |
Get the permissions of a file.
filename | The file to query |
filename
as permissions
, unless error, in which case -1On Windows the function always returns -1
|
inline |
|
inline |
|
inline |
void fs::make_dir | ( | std::string const & | abs_path, |
bool | recursive = true |
||
) |
Create a directory given an absolute path name.
abs_path | The absolute pathname of the directory to create. |
recursive | If true, then any non-existent prefixes of the required directory will also be created. Otherwise, the function will give a fatal error if any prefix does not exist. |
The function suceeds if abs_path
is an existing directory.
std::string fs::real_path | ( | std::string const & | relname | ) |
Get the absolute real pathname of a file or directory name.
Get the absolute real pathname of a file or directory name (which may be the name of a symbolic link).
relname | Possibly relative file or directory name. |
relname
. int fs::set_permissions | ( | std::string const & | filename, |
permissions | p | ||
) |
Set the permissions of a file.
filename | The file to modify |
p | The permissions to apply. |
The permission bits of p
are applied to filename
.
On Windows the function is a no-op.
std::string fs::tempname | ( | std::string const & | format | ) |
Create a tempory filename from a template.
format | A pathname pattern from which to compose the temporary filename. |
The string format
must terminate with XXXXXX
This suffix will be replaced, if possible, with a string of characters to compose a filename different from that of any existing file.