Rose
Classes | Public Types | Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
rose::XDGFilePaths Class Reference

A class to determine and provide searching of XDG standard files paths. More...

#include <XDGFilePaths.h>

Classes

struct  XDG_Env_Spec
 

Public Types

enum  XDG_Name : std::size_t {
  XDG_DATA_HOME, XDG_CONFIG_HOME, XDG_DATA_DIRS, XDG_CONFIG_DIRS,
  XDG_CACHE_HOME, XDG_RUNTIME_DIR
}
 
using XDG_Env_Var_List = std::array< XDG_Env_Spec, 6 >
 
using XDG_Path_Set = std::vector< std::filesystem::path >
 
using XDG_Paths = std::map< XDG_Name, XDG_Path_Set >
 

Public Member Functions

template<typename S >
std::tuple< bool, std::filesystem::path > findFilePath (XDG_Name name, const S &relativePath)
 Search for a relative path on one of the XDG standard locations. More...
 

Protected Attributes

XDG_Paths mPaths {}
 All the XDG specified paths.
 
std::string mHome
 User's home directory.
 

Static Protected Attributes

static constexpr XDG_Env_Var_List mEnvVars
 

Detailed Description

A class to determine and provide searching of XDG standard files paths.

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Member Function Documentation

◆ findFilePath()

template<typename S >
std::tuple<bool,std::filesystem::path> rose::XDGFilePaths::findFilePath ( XDG_Name  name,
const S &  relativePath 
)
inline

Search for a relative path on one of the XDG standard locations.

If the relative path is found below one of the specified paths in the named location, the return value is true with the full absolute path to the location. If not found the return value is false with the full absolute path to the relative location in the preferred directory.

Template Parameters
SThe type of the relative path, implicitly convertible to a std::string.
Parameters
nameThe XDG name
relativePathA path releative to an XDG location to search for.
Returns
A std::tuple<bool,std::filesystem::path>

Member Data Documentation

◆ mEnvVars

constexpr XDG_Env_Var_List rose::XDGFilePaths::mEnvVars
staticprotected
Initial value:
= {
XDG_Env_Spec{XDG_DATA_HOME, "XDG_DATA_HOME", ".local/share", true},
XDG_Env_Spec{XDG_CONFIG_HOME, "XDG_CONFIG_HOME", ".config", true},
XDG_Env_Spec{XDG_DATA_DIRS, "XDG_DATA_DIRS", "/usr/local/share/:/usr/share/", false},
XDG_Env_Spec{XDG_CONFIG_DIRS, "XDG_CONFIG_DIRS", "/etc/xdg", false},
XDG_Env_Spec{XDG_CACHE_HOME, "XDG_CACHE_HOME", ".cache", true},
XDG_Env_Spec{XDG_RUNTIME_DIR, "XDG_RUNTIME_DIR", "", false}
}

The documentation for this class was generated from the following files: