34 #include <boost/filesystem/path.hpp>
72 boost::filesystem::path xdg_temp_dir();
75 boost::filesystem::path xdg_getenv_path(
const std::string& env);
76 boost::filesystem::path xdg_path(
const std::string& env,
77 const boost::filesystem::path& default_path);
78 std::vector<boost::filesystem::path> xdg_paths(
const std::string& env,
79 const std::string& default_paths);
84 boost::filesystem::path xdg_find(
const boost::filesystem::path& file,
85 const std::vector<boost::filesystem::path>& dirs);
87 std::vector<boost::filesystem::path> xdg_findall(
const boost::filesystem::path& file,
88 const std::vector<boost::filesystem::path>& dirs);
90 void xdg_merge(
const boost::filesystem::path& file,
91 const std::vector<boost::filesystem::path>& dirs,
bool reverse,
92 std::function<
bool(
const boost::filesystem::path&)> mergefn);
97 return xdg_path(
"XDG_CONFIG_HOME",
"~/.config");
99 return xdg_path(
"XDG_CONFIG_HOME", xdg_getenv_path(
"LOCALAPPDATA"));
106 return xdg_path(
"XDG_DATA_HOME",
"~/.local/share");
108 return xdg_path(
"XDG_DATA_HOME", xdg_getenv_path(
"LOCALAPPDATA"));
115 return xdg_path(
"XDG_CACHE_HOME",
"~/.cache");
117 return xdg_path(
"XDG_CACHE_HOME", xdg_getenv_path(
"TEMP"));
124 return xdg_path(
"XDG_RUNTIME_DIR", xdg_temp_dir());
126 return xdg_path(
"XDG_CACHE_HOME", xdg_getenv_path(
"TEMP"));
133 return xdg_paths(
"XDG_CONFIG_DIRS",
"/etc/xdg");
135 return xdg_paths(
"XDG_CONFIG_DIRS", xdg_getenv_path(
"APPDATA").
string());
140 inline std::vector<boost::filesystem::path>
data_dirs() {
142 return xdg_paths(
"XDG_DATA_DIRS",
"/usr/local/share:/usr/share");
144 return xdg_paths(
"XDG_DATA_DIRS", xdg_getenv_path(
"APPDATA").
string());
167 inline boost::filesystem::path user_config(
const boost::filesystem::path& file) {
168 return config_home() / file;
170 inline boost::filesystem::path user_data(
const boost::filesystem::path& file) {
171 return data_home() / file;
173 inline boost::filesystem::path user_cache(
const boost::filesystem::path& file) {
176 inline boost::filesystem::path user_runtime(
const boost::filesystem::path& file) {
186 inline boost::filesystem::path find_config(
const boost::filesystem::path& file) {
189 inline boost::filesystem::path find_data(
const boost::filesystem::path& file) {
192 inline boost::filesystem::path find_cache(
const boost::filesystem::path& file) {
193 return xdg_find(file, std::vector<boost::filesystem::path>{
cache_home()});
195 inline boost::filesystem::path find_runtime(
const boost::filesystem::path& file) {
196 return xdg_find(file, std::vector<boost::filesystem::path>{
runtime_dir()});
205 inline std::vector<boost::filesystem::path> find_all_config(
const boost::filesystem::path& file) {
208 inline std::vector<boost::filesystem::path> find_all_data(
const boost::filesystem::path& file) {
220 inline void merge_config(
const boost::filesystem::path& file,
221 std::function<
bool(
const boost::filesystem::path&)>
223 bool reverse =
false) {
227 inline void merge_data(
const boost::filesystem::path& file,
228 std::function<
bool(
const boost::filesystem::path&)>
230 bool reverse =
false) {
boost::filesystem::path cache_home()
User cache files base directory, e.g., ~/.cache.
Definition: xdg.hpp:113
std::vector< boost::filesystem::path > config_dirs()
Global configuration directories, e.g., /etc/xdg.
Definition: xdg.hpp:131
std::vector< boost::filesystem::path > all_data_dirs()
User and global data directories.
Definition: xdg.hpp:156
boost::filesystem::path config_home()
User configuration base directory, e.g., ~./config.
Definition: xdg.hpp:95
std::vector< boost::filesystem::path > data_dirs()
Global data files directories, e.g., /usr/local/share.
Definition: xdg.hpp:140
XdgError
Definition: xdg.hpp:42
std::vector< boost::filesystem::path > all_config_dirs()
User and global configuration directories.
Definition: xdg.hpp:149
boost::filesystem::path data_home()
User data files base directory, e.g., ~/.local/share.
Definition: xdg.hpp:104
boost::filesystem::path runtime_dir()
User runtime files base directory, e.g., /run/user/1000
Definition: xdg.hpp:122