ase/path.hh file


Namespaces

namespace Ase
The Anklang C++ API namespace.
namespace Ase::Path
The Path namespace provides functions for file path manipulation and testing.

Functions

auto abspath(const String& path, const String& incwd) →  String
auto basename(const String& path) →  String
Strips all directory components from path and returns the resulting file name.
auto cache_home() →  String
Get the $XDG_CACHE_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
auto check(const String& file, const String& mode) →  bool
auto config_dirs() →  String
Get the $XDG_CONFIG_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/latest.
auto config_home() →  String
Get the $XDG_CONFIG_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
auto config_names() →  String
Get config names as set with config_names(), if unset defaults to program_alias().
void config_names(const String& names)
Set a colon separated list of names for this application to find configuration settings and files.
auto copy_file(const String& src, const String& dest) →  bool
Copy a file to a new non-existing location, sets errno and returns false on error.
auto cwd() →  String
Return the current working directoy, including symlinks used in $PWD if available.
auto data_dirs() →  String
Get the $XDG_DATA_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/latest.
auto data_home() →  String
Get the $XDG_DATA_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
auto dir_terminate(const String& path) →  String
Append trailing slash to path, unless it's present.
auto dircontains(const String& dirpath, const String& descendant, String* relpath) →  bool
Check if descendant belongs to the directory hierarchy under dirpath.
auto dirname(const String& path) →  String
Retrieve the directory part of the filename path.
auto equals(const String& file1, const String& file2) →  bool
auto expand_tilde(const String& path) →  String
Expand a "~/" or "~user/" path which refers to user home directories.
auto file_size(const String& path) →  size_t
Retrieve the on-disk size in bytes of path.
void glob(const String& pathpattern, StringS& matches)
Create list with filenames matching pathpattern with shell wildcards.
void glob(const String& pathpattern, StringS& dirs, StringS& files)
Create list with directories and filenames matching pathpattern with shell wildcards.
auto isabs(const String& path) →  bool
Return wether path is an absolute pathname.
auto isdirname(const String& path) →  bool
Return wether path is pointing to a directory component.
auto isroot(const String& path, bool dos_drives) →  bool
Return wether path is an absolute pathname which identifies the root directory.
auto join_with(const String& head, char joiner, const String& tail) →  String
Construct head + joiner + tail avoiding duplicates of joiner.
auto mkdirs(const String& dirpath, uint mode) →  bool
Create the directories in dirpath with mode, check errno on false returns.
auto normalize(const String& path) →  String
Convert path to normal form.
auto realpath(const String& path) →  String
Resolve links and directory references in path and provide a canonicalized absolute pathname.
void rglob(const String& basedir, const String& pattern, StringS& matches)
Recursively match files with glob pattern under basedir.
void rmrf(const String& dir)
Recursively delete directory tree.
auto runtime_dir() →  String
Get the $XDG_RUNTIME_DIR directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
auto searchpath_contains(const String& searchpath, const String& element) →  bool
Check if searchpath contains element, a trailing slash searches for directories.
auto searchpath_find(const String& searchpath, const String& file, const String& mode) →  String
Find the first file in searchpath which matches mode (see check()).
auto searchpath_list(const String& searchpath, const String& mode) →  StringS
Find all searchpath entries matching mode (see check()).
auto searchpath_multiply(const String& searchpath, const String& postfixes) →  String
Yield a new searchpath by combining each element of searchpath with each element of postfixes.
auto simplify_abspath(const std::string& abspath_expression) →  String
Remove extra slashes, './' and '../' from abspath_expression.
auto strip_slashes(const String& path) →  String
Strip trailing directory terminators.
void unique_realpaths(StringS& pathnames)
Convert all pathnames via realpath() and eliminate duplicates.
auto user_home(const String& username) →  String
Get a user's home directory, uses $HOME if no username is given.

Defines

#define ASE_DIRSEP
Platform directory separator character, '/' on Unix-like systems, a '\' on _WIN32.
#define ASE_DIRSEP2
Secondary directory separator character, '/' on Unix-like systems.
#define ASE_DIRSEPARATORS
List of platform directory separator characters, "/" on Unix-like systems, "/\\" on _WIN32.
#define ASE_DOS_PATHS
Equals 1 on _WIN32 and _WIN64 and 0 on Unix.
#define ASE_LIBEXT
Dynamic library filename extension on this platform.
#define ASE_SEARCHPATH_SEPARATOR
Platform searchpath separator, ':' on Unix-like systems, ';' on _WIN32.
#define ASE_UNIX_PATHS
Equals 0 on _WIN32 and _WIN64 and 1 on Unix.