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 just source code. Simply add it to your project and compile it statically with it.

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

By default, it is compiled as shared. You can define the BUILD_VARIANT_STATIC 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 it will be checked 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 it will be replaced by 0700 as defined by the specification).

If using CMake, CREATE_DIRS 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, NO_IGNORE_RELATIVE_DIRS can define the macro for you.