Prerequisites

This library is only intended for use on Unix systems; some features such as permissions may not work as expected on other operating systems.

Requirements:

  1. C++ compiler with support for C++17 or later
  2. libc++ that supports std::filesystem

Installing

This library is header-and-source. Simply add the source files to your project and compile them, or compile the library as a static library.

Alternatively, you can use the provided CMakeLists.txt file and compile it as a shared or static library.

By default, it is compiled as a shared library. You can define the BUILD_VARIANT_STATIC CMake variable to make it static.

Configuration

Custom string implementation

You can replace std::string with your own custom C++ string implementation by defining the UXDG_CUSTOM_STRING macro to be equal to the string's type. Then, you can define UXDG_CUSTOM_STRING_INCLUDE to be a string pointing to the header to include the string from.

Exporting functions from DLLs

If you want to export the symbols of the library out of a DLL, simply define the MLS_EXPORT_LIBRARY macro. Then, when building the library, make sure the macro MLS_LIB_COMPILE is enabled.

Users of CMake will have that enabled by default.

Create missing directories if found

If the UXDG_CREATE_DIRS macro is defined, when handling a directory, the library will check whether it exists. If it does not, it will be created with its appropriate permissions (adds 0700, except when the directory is XDG_RUNTIME_DIR, where the permissions will be set to 0700 as defined by the specification).

If using CMake, the CREATE_DIRS option can define the macro for you.

Disable ignoring relative directories

By enabling UXDG_DO_NOT_IGNORE_RELATIVE_DIRS, the file string will be checked to see if it's a relative path. The XDG Basedir specification ignores relative paths, so this feature may be useful if you do not want to ignore them.

If using CMake, the NO_IGNORE_RELATIVE_DIRS option can define the macro for you.