Anklang C++ API 0.0.0
Loading...
Searching...
No Matches
Ase::Path Namespace Reference

Typedefs

usingStringStringM = std::map< String, String >

Functions

Stringabspath (const String &path, const String &incwd)
Stringbasename (const String &path)
Stringcache_home ()
boolcheck (const String &file, const String &mode)
Stringconfig_dirs ()
Stringconfig_home ()
Stringconfig_names ()
voidconfig_names (const String &names)
boolcopy_file (const String &src, const String &dest)
Stringcwd ()
Stringdata_dirs ()
Stringdata_home ()
Stringdir_terminate (const String &path)
booldircontains (const String &dirpath, const String &descendant, String *relpath)
Stringdirname (const String &path)
boolequals (const String &file1, const String &file2)
Stringexpand_tilde (const String &path)
size_tfile_size (const String &path)
voidglob (const String &pathpattern, StringS &dirs, StringS &files)
voidglob (const String &pathpattern, StringS &matches)
boolisabs (const String &path)
boolisdirname (const String &path)
boolisroot (const String &path, bool dos_drives)
template<class ... S>
Stringjoin (String path, const S &...more)
Stringjoin_with (const String &head, char joiner, const String &tail)
voidmemfree (char *memread_mem)
char *memread (const String &filename, size_t *lengthp, ssize_t maxlength)
boolmemwrite (const String &filename, size_t len, const uint8 *bytes, bool append)
boolmkdirs (const String &dirpath, uint mode)
Stringnormalize (const String &path)
Stringrealpath (const String &path)
boolrename (const String &src, const String &dest)
voidrglob (const String &basedir, const String &pattern, StringS &matches)
voidrmrf (const String &dir)
Stringruntime_dir ()
boolsearchpath_contains (const String &searchpath, const String &element)
Stringsearchpath_find (const String &searchpath, const String &file, const String &mode)
Stringsearchpath_join (const StringS &string_vector)
template<class ... S>
Stringsearchpath_join (String path, const S &...more)
StringSsearchpath_list (const String &searchpath, const String &mode)
Stringsearchpath_multiply (const String &searchpath, const String &postfixes)
StringSsearchpath_split (const String &searchpath)
Stringsimplify_abspath (const std::string &abspath_expression)
Stringskip_root (const String &path)
StringPairsplit_extension (const std::string &filepath, const bool lastdot)
boolstringappend (const String &filename, const String &data, bool mkdirs_)
Stringstringread (const String &filename, ssize_t maxlength)
boolstringwrite (const String &filename, const String &data, bool mkdirs_)
Stringstrip_slashes (const String &path)
voidunique_realpaths (StringS &pathnames)
Stringuser_home (const String &username)
Stringvpath_find (const String &file, const String &mode)
Stringxdg_dir (const String &xdgdir)

Detailed Description

The Path namespace provides functions for file path manipulation and testing.

Typedef Documentation

StringStringM

using StringStringM = std::map<String,String>

Function Documentation

dirname()

String dirname ( const String & path)

Retrieve the directory part of the filename `path`.

basename()

String basename ( const String & path)

Strips all directory components from path and returns the resulting file name.

normalize()

String normalize ( const String & path)

Convert `path` to normal form.

realpath()

String realpath ( const String & path)

Resolve links and directory references in path and provide a canonicalized absolute pathname.

dir_terminate()

String dir_terminate ( const String & path)

Append trailing slash to `path`, unless it's present.

strip_slashes()

String strip_slashes ( const String & path)

Strip trailing directory terminators.

abspath()

String abspath ( const String & path,
const String & incwd
)
Parameters
patha filename path
incwdoptional current working directory

Complete path to become an absolute file path. If neccessary, incwd or the real current working directory is prepended.

isabs()

bool isabs ( const String & path)

Return wether path is an absolute pathname.

isroot()

bool isroot ( const String & path,
bool dos_drives
)

Return wether path is an absolute pathname which identifies the root directory.

isdirname()

bool isdirname ( const String & path)

Return wether path is pointing to a directory component.

mkdirs()

bool mkdirs ( const String & dirpath,
uint mode
)

Create the directories in `dirpath` with `mode`, check errno on false returns.

dircontains()

bool dircontains ( const String & dirpath,
const String & descendant,
String * relpath
)

Check if `descendant` belongs to the directory hierarchy under `dirpath`.

rmrf()

void rmrf ( const String & dir)

Recursively delete directory tree.

copy_file()

bool copy_file ( const String & src,
const String & dest
)

Copy a file to a new non-existing location, sets errno and returns false on error.

rename()

bool rename ( const String & src,
const String & dest
)

user_home()

String user_home ( const String & username)

Get a user's home directory, uses $HOME if no username is given.

data_home()

String data_home ( )

Get the $XDG_DATA_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.

config_home()

String config_home ( )

Get the $XDG_CONFIG_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.

cache_home()

String cache_home ( )

Get the $XDG_CACHE_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.

runtime_dir()

String runtime_dir ( )

Get the $XDG_RUNTIME_DIR directory, see: https://specifications.freedesktop.org/basedir-spec/latest.

xdg_dir()

String xdg_dir ( const String & xdgdir)

config_dirs()

String config_dirs ( )

Get the $XDG_CONFIG_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/latest.

data_dirs()

String data_dirs ( )

Get the $XDG_DATA_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/latest.

config_names() [1/2]

String config_names ( )

Get config names as set with config_names(), if unset defaults to program_alias().

config_names() [2/2]

void config_names ( const String & names)

Set a colon separated list of names for this application to find configuration settings and files.

split_extension()

StringPair split_extension ( const std::string & filepath,
const bool lastdot
)

expand_tilde()

String expand_tilde ( const String & path)

Expand a "~/" or "~user/" path which refers to user home directories.

skip_root()

String skip_root ( const String & path)

file_size()

size_t file_size ( const String & path)

Retrieve the on-disk size in bytes of `path`.

check()

bool check ( const String & file,
const String & mode
)
Parameters
filepossibly relative filename
modefeature string
Returns
true if file adhears to mode

Perform various checks on file and return whether all checks passed. On failure, errno is set appropriately, and FALSE is returned. Available features to be checked for are:

  • e - file must exist
  • r - file must be readable
  • w - file must be writable
  • x - file must be executable
  • f - file must be a regular file
  • d - file must be a directory
  • l - file must be a symbolic link
  • c - file must be a character device
  • b - file must be a block device
  • p - file must be a named pipe
  • s - file must be a socket.

equals()

bool equals ( const String & file1,
const String & file2
)
Parameters
file1possibly relative filename
file2possibly relative filename
Returns
TRUE if file1 and file2 are equal

Check whether file1 and file2 are pointing to the same inode in the same file system on the same device.

cwd()

String cwd ( )

Return the current working directoy, including symlinks used in $PWD if available.

searchpath_split()

StringS searchpath_split ( const String & searchpath)

searchpath_contains()

bool searchpath_contains ( const String & searchpath,
const String & element
)

Check if searchpath contains element, a trailing slash searches for directories.

searchpath_find()

String searchpath_find ( const String & searchpath,
const String & file,
const String & mode
)

Find the first file in searchpath which matches mode (see check()).

searchpath_list()

StringS searchpath_list ( const String & searchpath,
const String & mode
)

Find all searchpath entries matching mode (see check()).

join_with()

String join_with ( const String & head,
char joiner,
const String & tail
)

Construct `head + joiner + tail` avoiding duplicates of `joiner`.

searchpath_multiply()

String searchpath_multiply ( const String & searchpath,
const String & postfixes
)

Yield a new searchpath by combining each element of searchpath with each element of postfixes.

searchpath_join() [1/2]

String searchpath_join ( const StringS & string_vector)

vpath_find()

String vpath_find ( const String & file,
const String & mode
)

glob() [1/2]

void glob ( const String & pathpattern,
StringS & dirs,
StringS & files
)

Create list with directories and filenames matching `pathpattern` with shell wildcards.

glob() [2/2]

void glob ( const String & pathpattern,
StringS & matches
)

Create list with filenames matching `pathpattern` with shell wildcards.

rglob()

void rglob ( const String & basedir,
const String & pattern,
StringS & matches
)

Recursively match files with glob `pattern` under `basedir`.

unique_realpaths()

void unique_realpaths ( StringS & pathnames)

Convert all `pathnames` via realpath() and eliminate duplicates.

simplify_abspath()

String simplify_abspath ( const std::string & abspath_expression)

Remove extra slashes, './' and '../' from `abspath_expression`.

memread()

char * memread ( const String & filename,
size_t * lengthp,
ssize_t maxlength
)

memfree()

void memfree ( char * memread_mem)

memwrite()

bool memwrite ( const String & filename,
size_t len,
const uint8 * bytes,
bool append
)

stringread()

String stringread ( const String & filename,
ssize_t maxlength
)

stringwrite()

bool stringwrite ( const String & filename,
const String & data,
bool mkdirs_
)

stringappend()

bool stringappend ( const String & filename,
const String & data,
bool mkdirs_
)

join()

template<class ... S>
String join ( String path,
const S &... more
)

searchpath_join() [2/2]

template<class ... S>
String searchpath_join ( String path,
const S &... more
)