SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
pathops.hpp File Reference

Helpers dealing with file system paths. More...

Go to the source code of this file.

Namespaces

 shore
 SHORE core API.
 

Constant Groups

 shore
 SHORE core API.
 

Functions

std::string shore::home ()
 Get the current user's home directory.
 
std::string shore::config_home ()
 Get the config file directory for the current user (usually ~/.config/).
 
std::string shore::expand_home (const std::string &path)
 Expand leading tilde '~' char into the current user's home directory.
 
std::string shore::path_parent (const std::string &path)
 Get the parent directory for a path.
 
std::string shore::path_leaf (const std::string &path)
 Get only the last element in a path.
 
std::string shore::path_trunk (const std::string &path)
 Get only the first element in a path.
 
std::string shore::path_clean (const std::string &path)
 Make a path absolute and remove "." and ".." nodes and multiple slashes.
 
std::string shore::path_enum (const std::string &path, const std::string &suffix, int &num_ofs, const char sep='_')
 Increment a counter until the file <path><sep><counter><suffix> does not exist.
 
std::string shore::path_enum (const std::string &path, const std::string &suffix=std::string())
 Increment a counter until the file <path>_<counter><suffix> does not exist.
 
bool shore::is_executable (const std::string &fn)
 Test if a path points to a file that we're permitted to execute.
 
std::string shore::mktempdir (const std::string &prefix)
 Create a temporary file directory with the given path prefix. More...
 
std::string shore::which_nofail (const std::string &command, const std::string &env=std::string())
 Equivalent to the shell command.
 
uint64_t shore::file_size (const std::string &fn)
 Get the size of a file.
 
void shore::toupper (std::string &str)
 In-place conversion to upper case.
 
template<class Ex >
std::string shore::which_fail (const std::string &command, const std::string &env=std::string())
 Equivalent to the shell command.
 
std::string shore::which (const std::string &command, const std::string &env=std::string())
 Equivalent to the shell command.
 
template<class Iter >
void shore::glob (Iter b, Iter e, std::vector< std::string > &ret)
 
template<class Iter >
std::vector< std::string > shore::glob (Iter b, Iter e)
 Find files matching the given glob pattern.
 
void shore::glob (const std::string &pattern, std::vector< std::string > &ret)
 Find files matching the given glob pattern.
 
std::vector< std::string > shore::glob (const std::string &pattern)
 Find files matching the given glob pattern.
 
uint64_t shore::get_mtime (const std::string &path)
 Get the modification time for a path.
 
bool shore::is_older (const std::string &path1, const std::string &path2)
 Test if path1 modification time is older than the one for path2.
 

Detailed Description

Helpers dealing with file system paths.

Author
Felix Ott