8#define ASE_UNIX_PATHS 0
11#define ASE_DIRSEP2 '\\'
12#define ASE_DIRSEPARATORS "/\\"
13#define ASE_SEARCHPATH_SEPARATOR ';'
14#define ASE_LIBEXT ".dll"
16#define ASE_UNIX_PATHS 1
17#define ASE_DOS_PATHS 0
19#define ASE_DIRSEP2 '/'
20#define ASE_DIRSEPARATORS "/"
21#define ASE_SEARCHPATH_SEPARATOR ':'
22#define ASE_LIBEXT ".so"
24#define ASE_PATH_MAX (PATH_MAX > 4096 ? PATH_MAX : 4096)
47StringPair split_extension (
const std::string &filepath,
bool lastdot =
false);
64char* memread (
const String &filename,
size_t *lengthp,
ssize_t maxlength = -1);
65void memfree (
char *memread_mem);
66bool memwrite (
const String &filename,
size_t len,
const uint8 *bytes,
bool append =
false,
int perms = -1);
68bool stringwrite (
const String &filename,
const String &data,
bool mkdirs =
false,
int perms = -1);
69bool stringappend (
const String &filename,
const String &data,
bool mkdirs =
false,
int perms = -1);
89template<
class ...S>
inline String
90join (
String path,
const S &...more)
96template<
class ...S>
inline String
97searchpath_join (
String path,
const S &...more)
String user_home(const String &username)
Get a user's home directory, uses $HOME if no username is given.
String cwd()
Return the current working directoy, including symlinks used in $PWD if available.
bool searchpath_contains(const String &searchpath, const String &element)
Check if searchpath contains element, a trailing slash searches for directories.
String config_dirs()
Get the $XDG_CONFIG_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/lat...
void unique_realpaths(StringS &pathnames)
Convert all pathnames via realpath() and eliminate duplicates.
String config_names()
Get config names as set with config_names(), if unset defaults to program_alias().
String config_home()
Get the $XDG_CONFIG_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
String searchpath_multiply(const String &searchpath, const String &postfixes)
Yield a new searchpath by combining each element of searchpath with each element of postfixes.
bool mkdirs(const String &dirpath, uint mode)
Create the directories in dirpath with mode, check errno on false returns.
bool check(const String &file, const String &mode)
String expand_tilde(const String &path)
Expand a "~/" or "~user/" path which refers to user home directories.
bool equals(const String &file1, const String &file2)
String dir_terminate(const String &path)
Append trailing slash to path, unless it's present.
String simplify_abspath(const std::string &abspath_expression)
Remove extra slashes, './' and '../' from abspath_expression.
bool isdirname(const String &path)
Return wether path is pointing to a directory component.
String strip_slashes(const String &path)
Strip trailing directory terminators.
String data_home()
Get the $XDG_DATA_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
String cache_home()
Get the $XDG_CACHE_HOME directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
String join_with(const String &head, char joiner, const String &tail)
Construct head + joiner + tail avoiding duplicates of joiner.
String runtime_dir()
Get the $XDG_RUNTIME_DIR directory, see: https://specifications.freedesktop.org/basedir-spec/latest.
String searchpath_find(const String &searchpath, const String &file, const String &mode)
Find the first file in searchpath which matches mode (see check()).
String abspath(const String &path, const String &incwd)
void rmrf(const String &dir)
Recursively delete directory tree.
size_t file_size(const String &path)
Retrieve the on-disk size in bytes of path.
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.
bool isabs(const String &path)
Return wether path is an absolute pathname.
bool isroot(const String &path, bool dos_drives)
Return wether path is an absolute pathname which identifies the root directory.
String data_dirs()
Get the $XDG_DATA_DIRS directory list, see: https://specifications.freedesktop.org/basedir-spec/lates...
bool dircontains(const String &dirpath, const String &descendant, String *relpath)
Check if descendant belongs to the directory hierarchy under dirpath.
void rglob(const String &basedir, const String &pattern, StringS &matches)
Recursively match files with glob pattern under basedir.
StringS searchpath_list(const String &searchpath, const String &mode)
Find all searchpath entries matching mode (see check()).
String normalize(const String &path)
Convert path to normal form.
The Anklang C++ API namespace.
uint8_t uint8
An 8-bit unsigned integer.
std::vector< String > StringS
Convenience alias for a std::vector<std::string>.
std::string String
Convenience alias for std::string.
uint32_t uint
Provide 'uint' as convenience type.
#define ASE_DOS_PATHS
Equals 1 on _WIN32 and _WIN64 and 0 on Unix.
#define ASE_DIRSEP
Platform directory separator character, '/' on Unix-like systems, a '\' on _WIN32.
#define ASE_SEARCHPATH_SEPARATOR
Platform searchpath separator, ':' on Unix-like systems, ';' on _WIN32.