MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
shcore::path Namespace Reference

Namespaces

namespace  detail
 

Functions

std::string search_stdpath (const std::string &name)
 Returns path to the given executable name searched in PATH. More...
 
std::string search_path_list (const std::string &name, const std::string &pathlist, const char separator=0)
 Returns path to the given executable name searched in the given path list string, separated by the given separator. More...
 
bool is_path_separator (char c)
 Checks if character is a path separator. More...
 
std::string join_path (const std::vector< std::string > &components)
 
std::string join_path (const std::string &a, const std::string &b)
 
template<typename... Args>
std::string join_path (const std::string &a, const std::string &b, Args... args)
 
std::pair< std::string, std::string > splitdrive (const std::string &path)
 
std::string dirname (const std::string &path)
 
std::string basename (const std::string &path)
 
std::string home ()
 Get home directory path of the user executing the shell. More...
 
std::string home (const std::string &loginname)
 Get home directory path of user associated with the specified login name. More...
 
std::string expand_user (const std::string &path)
 expand_user expand paths beginning with ~ or ~user (also known as "tilde expansion"). More...
 
std::string normalize (const std::string &path)
 Unix: Normalize a path collapsing redundant separators and relative references. More...
 
std::tuple< std::string, std::string > split_extension (const std::string &path)
 Split path to (root, extension) tuple such that [root + extenstion == path]. More...
 
bool exists (const std::string &path)
 Returns true if the path exists. More...
 
bool is_absolute (const std::string &path)
 Checks if path is absolute. More...
 
std::string getcwd ()
 Provides path to the current working directory. More...
 
std::string tmpdir ()
 
std::string errno_to_string (int err)
 

Variables

const char path_separator = '/'
 
const char pathlist_separator = ':'
 
const char pathlist_separator_s [] = {pathlist_separator, '\0'}
 
const char * k_valid_path_separators = "/"
 

Function Documentation

◆ basename()

std::string shcore::path::basename ( const std::string &  path)

◆ dirname()

std::string shcore::path::dirname ( const std::string &  path)

◆ errno_to_string()

std::string shcore::path::errno_to_string ( int  err)

◆ exists()

bool shcore::path::exists ( const std::string &  path)

Returns true if the path exists.

◆ expand_user()

std::string shcore::path::expand_user ( const std::string &  path)

expand_user expand paths beginning with ~ or ~user (also known as "tilde expansion").

Home directory for ~ prefix is obtained by home() function. Home directory for ~user prefix is obtained by home(user) function.

Parameters
pathPath string.
Returns
Return path with prefix ~ or ~user replaced by that user's home directory.
See also
home() and
home(user). If the expansion fails or if the path does not begin with ~, the path is returned unchanged.

◆ getcwd()

std::string shcore::path::getcwd ( )

Provides path to the current working directory.

◆ home() [1/2]

std::string shcore::path::home ( )

Get home directory path of the user executing the shell.

On Unix: HOME environment variable is returned if is set, otherwise current user home directory is looked up in password directory.

On Windows: HOME% or USERPROFILE% or HOMEDRIVE% + HOMEPATH% environment variable is returned if is set, otherwise user home directory is obtained from system KnownFolder ID FOLDERID_Profile. If all of above fail, empty string is returned.

Returns
User home directory path.

◆ home() [2/2]

std::string shcore::path::home ( const std::string &  loginname)

Get home directory path of user associated with the specified login name.

On Unix: User home directory path associated with loginname is looked up directly in the password directory.

On Windows: Retrieving home directory of another user on Windows platform is NOT SUPPORTED.

Parameters
loginnameLogin name of existing user in system.
Returns
User home directory associated with loginname or empty string if such user does not exist.

◆ is_absolute()

bool shcore::path::is_absolute ( const std::string &  path)

Checks if path is absolute.

Parameters
path- path to be checked.
Returns
true if the given path is absolute.

◆ is_path_separator()

bool shcore::path::is_path_separator ( char  c)

Checks if character is a path separator.

Parameters
c- character to be checked.
Returns
true if the given character is a path separator.

◆ join_path() [1/3]

std::string shcore::path::join_path ( const std::string &  a,
const std::string &  b 
)
inline

◆ join_path() [2/3]

template<typename... Args>
std::string shcore::path::join_path ( const std::string &  a,
const std::string &  b,
Args...  args 
)

◆ join_path() [3/3]

std::string shcore::path::join_path ( const std::vector< std::string > &  components)

◆ normalize()

std::string shcore::path::normalize ( const std::string &  path)

Unix: Normalize a path collapsing redundant separators and relative references.

This string path manipulation, might affect paths containing symbolic links.

Windows: Retrieves the full path and file name of the specified file. If error occur path isn't altered.

Parameters
pathInput path string to normalize.
Returns
Normalized string path.

◆ search_path_list()

std::string shcore::path::search_path_list ( const std::string &  name,
const std::string &  pathlist,
const char  separator = 0 
)

Returns path to the given executable name searched in the given path list string, separated by the given separator.

Parameters
namename of the executable. .exe is automatically appended in Win32
pathliststring with list of paths to search
separatorseparator character used in pathlist. If 0, the default PATH separator for the platform is used.

◆ search_stdpath()

std::string shcore::path::search_stdpath ( const std::string &  name)

Returns path to the given executable name searched in PATH.

◆ split_extension()

std::tuple< std::string, std::string > shcore::path::split_extension ( const std::string &  path)

Split path to (root, extension) tuple such that [root + extenstion == path].

Parameters
pathOriginal file name
Returns
Tuple (root, extension). Leading periods on basename are ignored, i.e. split_extension(".dotfile") returns (".dotfile", "").

◆ splitdrive()

std::pair< std::string, std::string > shcore::path::splitdrive ( const std::string &  path)

◆ tmpdir()

std::string shcore::path::tmpdir ( )

Variable Documentation

◆ k_valid_path_separators

const char * shcore::path::k_valid_path_separators = "/"

◆ path_separator

const char shcore::path::path_separator = '/'

◆ pathlist_separator

const char shcore::path::pathlist_separator = ':'

◆ pathlist_separator_s

const char shcore::path::pathlist_separator_s[] = {pathlist_separator, '\0'}