aboutsummaryrefslogtreecommitdiff
path: root/source/lib/src/xdg.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2023-08-17 12:32:50 +0200
committerFelix Morgner <felix.morgner@gmail.com>2023-08-17 12:32:50 +0200
commit375799fa79d1af76f33299acc20a11a167a021f8 (patch)
tree8f91b982ec96225c33a2f4871730ababffe5cab0 /source/lib/src/xdg.cpp
parentaf471b9b780869915d3217b228e24d025892de47 (diff)
downloadwanda-375799fa79d1af76f33299acc20a11a167a021f8.tar.xz
wanda-375799fa79d1af76f33299acc20a11a167a021f8.zip
project: restructure libraries and build env
Diffstat (limited to 'source/lib/src/xdg.cpp')
-rw-r--r--source/lib/src/xdg.cpp46
1 files changed, 0 insertions, 46 deletions
diff --git a/source/lib/src/xdg.cpp b/source/lib/src/xdg.cpp
deleted file mode 100644
index cfd1719..0000000
--- a/source/lib/src/xdg.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "wanda/xdg.hpp"
-
-#include <unistd.h>
-
-namespace wanda
-{
- std::string xdg_variable(xdg_directory directory)
- {
- switch (directory)
- {
- case xdg_directory::data_home:
- return "XDG_DATA_HOME";
- case xdg_directory::config_home:
- return "XDG_CONFIG_HOME";
- case xdg_directory::cache_home:
- return "XDG_CACHE_HOME";
- case xdg_directory::runtime_dir:
- return "XDG_RUNTIME_DIR";
- }
- return "XDG_INVALID_PATH";
- }
-
- std::filesystem::path xdg_path_for(xdg_directory directory, environment const & environment)
- {
- if (auto path = environment[xdg_variable(directory)]; !path.empty())
- {
- return path;
- }
-
- auto home = std::filesystem::path{environment["HOME"]};
- switch (directory)
- {
- case xdg_directory::data_home:
- return home / ".local/share";
- case xdg_directory::config_home:
- return home / ".config";
- case xdg_directory::cache_home:
- return home / ".cache";
- case xdg_directory::runtime_dir:
- return std::filesystem::path{"/run/user"} / std::to_string(::getuid());
- }
-
- return "";
- }
-
-} // namespace wanda \ No newline at end of file