28 #ifndef CLOE_UTILITY_XDG_HPP_ 29 #define CLOE_UTILITY_XDG_HPP_ 35 #include <boost/filesystem/path.hpp> 73 boost::filesystem::path xdg_temp_dir();
76 boost::filesystem::path xdg_getenv_path(
const std::string& env);
77 boost::filesystem::path xdg_path(
const std::string& env,
78 const boost::filesystem::path& default_path);
79 std::vector<boost::filesystem::path> xdg_paths(
const std::string& env,
80 const std::string& default_paths);
85 boost::filesystem::path xdg_find(
const boost::filesystem::path& file,
86 const std::vector<boost::filesystem::path>& dirs);
88 std::vector<boost::filesystem::path> xdg_findall(
const boost::filesystem::path& file,
89 const std::vector<boost::filesystem::path>& dirs);
91 void xdg_merge(
const boost::filesystem::path& file,
92 const std::vector<boost::filesystem::path>& dirs,
bool reverse,
93 std::function<
bool(
const boost::filesystem::path&)> mergefn);
98 return xdg_path(
"XDG_CONFIG_HOME",
"~/.config");
100 return xdg_path(
"XDG_CONFIG_HOME", xdg_getenv_path(
"LOCALAPPDATA"));
107 return xdg_path(
"XDG_DATA_HOME",
"~/.local/share");
109 return xdg_path(
"XDG_DATA_HOME", xdg_getenv_path(
"LOCALAPPDATA"));
116 return xdg_path(
"XDG_CACHE_HOME",
"~/.cache");
118 return xdg_path(
"XDG_CACHE_HOME", xdg_getenv_path(
"TEMP"));
125 return xdg_path(
"XDG_RUNTIME_DIR", xdg_temp_dir());
127 return xdg_path(
"XDG_CACHE_HOME", xdg_getenv_path(
"TEMP"));
134 return xdg_paths(
"XDG_CONFIG_DIRS",
"/etc/xdg");
136 return xdg_paths(
"XDG_CONFIG_DIRS", xdg_getenv_path(
"APPDATA").
string());
141 inline std::vector<boost::filesystem::path>
data_dirs() {
143 return xdg_paths(
"XDG_DATA_DIRS",
"/usr/local/share:/usr/share");
145 return xdg_paths(
"XDG_DATA_DIRS", xdg_getenv_path(
"APPDATA").
string());
168 inline boost::filesystem::path user_config(
const boost::filesystem::path& file) {
171 inline boost::filesystem::path user_data(
const boost::filesystem::path& file) {
174 inline boost::filesystem::path user_cache(
const boost::filesystem::path& file) {
177 inline boost::filesystem::path user_runtime(
const boost::filesystem::path& file) {
187 inline boost::filesystem::path find_config(
const boost::filesystem::path& file) {
190 inline boost::filesystem::path find_data(
const boost::filesystem::path& file) {
193 inline boost::filesystem::path find_cache(
const boost::filesystem::path& file) {
194 return xdg_find(file, std::vector<boost::filesystem::path>{
cache_home()});
196 inline boost::filesystem::path find_runtime(
const boost::filesystem::path& file) {
197 return xdg_find(file, std::vector<boost::filesystem::path>{
runtime_dir()});
206 inline std::vector<boost::filesystem::path> find_all_config(
const boost::filesystem::path& file) {
209 inline std::vector<boost::filesystem::path> find_all_data(
const boost::filesystem::path& file) {
221 inline void merge_config(
const boost::filesystem::path& file,
222 std::function<
bool(
const boost::filesystem::path&)>
224 bool reverse =
false) {
228 inline void merge_data(
const boost::filesystem::path& file,
229 std::function<
bool(
const boost::filesystem::path&)>
231 bool reverse =
false) {
238 #endif // CLOE_UTILITY_XDG_HPP_ XdgError
Definition: xdg.hpp:43
std::vector< boost::filesystem::path > all_data_dirs()
User and global data directories.
Definition: xdg.hpp:157
boost::filesystem::path config_home()
User configuration base directory, e.g., ~./config.
Definition: xdg.hpp:96
Definition: coordinator.hpp:36
std::vector< boost::filesystem::path > data_dirs()
Global data files directories, e.g., /usr/local/share.
Definition: xdg.hpp:141
std::vector< boost::filesystem::path > all_config_dirs()
User and global configuration directories.
Definition: xdg.hpp:150
boost::filesystem::path runtime_dir()
User runtime files base directory, e.g., /run/user/1000
Definition: xdg.hpp:123
boost::filesystem::path data_home()
User data files base directory, e.g., ~/.local/share.
Definition: xdg.hpp:105
std::vector< boost::filesystem::path > config_dirs()
Global configuration directories, e.g., /etc/xdg.
Definition: xdg.hpp:132
boost::filesystem::path cache_home()
User cache files base directory, e.g., ~/.cache.
Definition: xdg.hpp:114