Skip to content

Namespace Ase::Path

Namespace List > Ase > Path

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

Public Types

Type Name
typedef std::map< String, String > StringStringM

Public Functions

Type Name
String abspath (const String & path, const String & incwd)
String basename (const String & path)
Strips all directory components from path and returns the resulting file name.
String cache_home ()
Get the $XDG_CACHE_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest .
bool check (const String & file, const String & mode)
String config_dirs ()
Get the $XDG_CONFIG_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/latest .
String config_home ()
Get the $XDG_CONFIG_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest .
String config_names ()
Get config names as set with config_names() , if unset defaults toprogram_alias() .
void config_names (const String & names)
Set a colon separated list of names for this application to find configuration settings and files.
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.
String cwd ()
Return the current working directoy, including symlinks used in $PWD if available.
String data_dirs ()
Get the $XDG_DATA_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/latest .
String data_home ()
Get the $XDG_DATA_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest .
String dir_terminate (const String & path)
Append trailing slash to path , unless it's present.
bool dircontains (const String & dirpath, const String & descendant, String * relpath)
Check if descendant belongs to the directory hierarchy underdirpath .
String dirname (const String & path)
Retrieve the directory part of the filename path .
bool equals (const String & file1, const String & file2)
String expand_tilde (const String & path)
Expand a "~/" or "~user/" path which refers to user home directories.
size_t file_size (const String & path)
Retrieve the on-disk size in bytes of path .
void glob (const String & pathpattern, StringS & dirs, StringS & files)
Create list with directories and filenames matching pathpattern with shell wildcards.
void glob (const String & pathpattern, StringS & matches)
Create list with filenames matching pathpattern with shell wildcards.
bool isabs (const String & path)
Return wether path is an absolute pathname.
bool isdirname (const String & path)
Return wether path is pointing to a directory component.
bool isroot (const String & path, bool dos_drives)
Return wether path is an absolute pathname which identifies the root directory.
String join (String path, const S &... more)
String join_with (const String & head, char joiner, const String & tail)
Construct head + joiner + tail avoiding duplicates ofjoiner .
void memfree (char * memread_mem)
char * memread (const String & filename, size_t * lengthp, ssize_t maxlength)
bool memwrite (const String & filename, size_t len, const uint8 * bytes, bool append)
bool mkdirs (const String & dirpath, uint mode)
Create the directories in dirpath withmode , check errno on false returns.
String normalize (const String & path)
Convert path to normal form.
String realpath (const String & path)
Resolve links and directory references in path and provide a canonicalized absolute pathname.
bool rename (const String & src, const String & dest)
void rglob (const String & basedir, const String & pattern, StringS & matches)
Recursively match files with glob pattern underbasedir .
void rmrf (const String & dir)
Recursively delete directory tree.
String runtime_dir ()
Get the $XDG_RUNTIME_DIR directory, see: https://specifications.freedesktop.org/basedir-spec/latest .
bool searchpath_contains (const String & searchpath, const String & element)
Check if searchpath contains__element , a trailing slash searches for directories.
String searchpath_find (const String & searchpath, const String & file, const String & mode)
Find the first file in__searchpath which matches__mode (seecheck() ).
String searchpath_join (const StringS & string_vector)
String searchpath_join (String path, const S &... more)
StringS searchpath_list (const String & searchpath, const String & mode)
Find all searchpath entries matching__mode (seecheck() ).
String searchpath_multiply (const String & searchpath, const String & postfixes)
Yield a new searchpath by combining each element of searchpath with each element of__postfixes .
StringS searchpath_split (const String & searchpath)
String simplify_abspath (const std::string & abspath_expression)
Remove extra slashes, './' and '../' from abspath_expression .
String skip_root (const String & path)
StringPair split_extension (const std::string & filepath, const bool lastdot)
bool stringappend (const String & filename, const String & data, bool mkdirs_)
String stringread (const String & filename, ssize_t maxlength)
bool stringwrite (const String & filename, const String & data, bool mkdirs_)
String strip_slashes (const String & path)
Strip trailing directory terminators.
void unique_realpaths (StringS & pathnames)
Convert all pathnames viarealpath() and eliminate duplicates.
String user_home (const String & username)
Get a user's home directory, uses $HOME if no__username is given.
String vpath_find (const String & file, const String & mode)
String xdg_dir (const String & xdgdir)

Public Static Functions

Type Name
String access_config_names (const String * newval)
int errno_check_file (const char * file_name, const char * mode)
char * file_memread (FILE * stream, size_t * lengthp, ssize_t maxlength)
bool startswith_dosdrive (const char * p)
bool startswith_dosdrive (const String & s)
StringStringM xdg_user_dirs ()

Public Types Documentation

typedef StringStringM

using Ase::Path::StringStringM = typedef std::map<String,String>;

Public Functions Documentation

function abspath

String Ase::Path::abspath (
    const String & path,
    const String & incwd
) 

Parameters:

  • path a filename path
  • incwd optional current working directory

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


function basename

String Ase::Path::basename (
    const String & path
) 

function cache_home

String Ase::Path::cache_home () 

function check

bool Ase::Path::check (
    const String & file,
    const String & mode
) 

Parameters:

  • file possibly relative filename
  • mode feature 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.


function config_dirs

String Ase::Path::config_dirs () 

function config_home

String Ase::Path::config_home () 

function config_names

String Ase::Path::config_names () 

function config_names

void Ase::Path::config_names (
    const String & names
) 

function copy_file

bool Ase::Path::copy_file (
    const String & src,
    const String & dest
) 

function cwd

String Ase::Path::cwd () 

function data_dirs

String Ase::Path::data_dirs () 

function data_home

String Ase::Path::data_home () 

function dir_terminate

String Ase::Path::dir_terminate (
    const String & path
) 

function dircontains

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

function dirname

String Ase::Path::dirname (
    const String & path
) 

function equals

bool Ase::Path::equals (
    const String & file1,
    const String & file2
) 

Parameters:

  • file1 possibly relative filename
  • file2 possibly 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.


function expand_tilde

String Ase::Path::expand_tilde (
    const String & path
) 

function file_size

size_t Ase::Path::file_size (
    const String & path
) 

function glob

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

function glob

void Ase::Path::glob (
    const String & pathpattern,
    StringS & matches
) 

function isabs

bool Ase::Path::isabs (
    const String & path
) 

function isdirname

bool Ase::Path::isdirname (
    const String & path
) 

function isroot

bool Ase::Path::isroot (
    const String & path,
    bool dos_drives
) 

function join

template<class ... S>
inline String Ase::Path::join (
    String path,
    const S &... more
) 

function join_with

String Ase::Path::join_with (
    const String & head,
    char joiner,
    const String & tail
) 

function memfree

void Ase::Path::memfree (
    char * memread_mem
) 

function memread

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

function memwrite

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

function mkdirs

bool Ase::Path::mkdirs (
    const String & dirpath,
    uint mode
) 

function normalize

String Ase::Path::normalize (
    const String & path
) 

function realpath

String Ase::Path::realpath (
    const String & path
) 

function rename

bool Ase::Path::rename (
    const String & src,
    const String & dest
) 

function rglob

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

function rmrf

void Ase::Path::rmrf (
    const String & dir
) 

function runtime_dir

String Ase::Path::runtime_dir () 

function searchpath_contains

bool Ase::Path::searchpath_contains (
    const String & searchpath,
    const String & element
) 

function searchpath_find

String Ase::Path::searchpath_find (
    const String & searchpath,
    const String & file,
    const String & mode
) 

function searchpath_join

String Ase::Path::searchpath_join (
    const StringS & string_vector
) 

function searchpath_join

template<class ... S>
inline String Ase::Path::searchpath_join (
    String path,
    const S &... more
) 

function searchpath_list

StringS Ase::Path::searchpath_list (
    const String & searchpath,
    const String & mode
) 

function searchpath_multiply

String Ase::Path::searchpath_multiply (
    const String & searchpath,
    const String & postfixes
) 

function searchpath_split

StringS Ase::Path::searchpath_split (
    const String & searchpath
) 

function simplify_abspath

String Ase::Path::simplify_abspath (
    const std::string & abspath_expression
) 

function skip_root

String Ase::Path::skip_root (
    const String & path
) 

function split_extension

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

function stringappend

bool Ase::Path::stringappend (
    const String & filename,
    const String & data,
    bool mkdirs_
) 

function stringread

String Ase::Path::stringread (
    const String & filename,
    ssize_t maxlength
) 

function stringwrite

bool Ase::Path::stringwrite (
    const String & filename,
    const String & data,
    bool mkdirs_
) 

function strip_slashes

String Ase::Path::strip_slashes (
    const String & path
) 

function unique_realpaths

void Ase::Path::unique_realpaths (
    StringS & pathnames
) 

function user_home

String Ase::Path::user_home (
    const String & username
) 

function vpath_find

String Ase::Path::vpath_find (
    const String & file,
    const String & mode
) 

function xdg_dir

String Ase::Path::xdg_dir (
    const String & xdgdir
) 

Public Static Functions Documentation

function access_config_names

static String Ase::Path::access_config_names (
    const String * newval
) 

function errno_check_file

static int Ase::Path::errno_check_file (
    const char * file_name,
    const char * mode
) 

function file_memread

static char * Ase::Path::file_memread (
    FILE * stream,
    size_t * lengthp,
    ssize_t maxlength
) 

function startswith_dosdrive

static bool Ase::Path::startswith_dosdrive (
    const char * p
) 

function startswith_dosdrive

static bool Ase::Path::startswith_dosdrive (
    const String & s
) 

function xdg_user_dirs

static StringStringM Ase::Path::xdg_user_dirs () 


The documentation for this class was generated from the following file /__w/anklang/anklang/ase/path.cc