coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
fs Namespace Reference

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)
 

Detailed Description

Namespace fs encloses filesystem operations.

Enumeration Type Documentation

anonymous enum

Symbolic constants denoting filesystem objects.

Enumerator
OBJ_NONE 

No such object.

OBJ_SLINK 

A symbolic link.

OBJ_FILE 

A file.

OBJ_DIR 

A directory.

Definition at line 49 of file filesys.h.

Function Documentation

std::string fs::abs_path ( std::string const &  filename)

Get the absolute pathname for a filename.

Parameters
filenameAn absolute or relative pathname that need not refer to any existing object.
Returns
If 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.

Parameters
filenameThe file to query
Returns
The file-permission bits of filename as permissions, unless error, in which case -1

On Windows the function always returns -1

bool fs::is_dir ( obj_type_t  type)
inline

Say whether an object type is a directory.

Parameters
typeThe object type to be tested.
Returns
True iff type denotes a directory.

Definition at line 76 of file filesys.h.

bool fs::is_file ( obj_type_t  type)
inline

Say whether an object type is a file.

Parameters
typeThe object type to be tested.
Returns
True iff type denotes a file.

Definition at line 67 of file filesys.h.

bool fs::is_slink ( obj_type_t  type)
inline

Say whether an object type is a symbolic link.

Parameters
typeThe object type to be tested.
Returns
True iff type denotes a symbolic link.

Definition at line 85 of file filesys.h.

void fs::make_dir ( std::string const &  abs_path,
bool  recursive = true 
)

Create a directory given an absolute path name.

Parameters
abs_pathThe absolute pathname of the directory to create.
recursiveIf 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).

Parameters
relnamePossibly relative file or directory name.
Returns
The absolute real pathname of relname.
int fs::set_permissions ( std::string const &  filename,
permissions  p 
)

Set the permissions of a file.

Parameters
filenameThe file to modify
pThe permissions to apply.
Returns
0 unless error, in which case -1

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.

Parameters
formatA pathname pattern from which to compose the temporary filename.
Returns
A temporary filename if one can be created, otherwise an empty string.

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.