浏览代码

prefer XDG paths on mac, but default to ~/Library

if a user has XDG_* paths setup on mac, it's more than likely those were
explicitly defined and therefore the preferred mechanism for organizing
such fs data. the ~/Library paths are sensible default alternatives,
but providing a way to override them (via the environment rather than
command-line arguments) is not only convenient but also consistent with
linux/fbsd path behavior
better_mac_paths
John Robinson 3 年前
父节点
当前提交
fe22c937ed
找不到此签名对应的密钥
共有 1 个文件被更改,包括 24 次插入3 次删除
  1. +24
    -3
      src/dds/util/paths.macos.cpp

+ 24
- 3
src/dds/util/paths.macos.cpp 查看文件

@@ -19,8 +19,29 @@ fs::path dds::user_home_dir() {
return ret;
}

fs::path dds::user_data_dir() { return user_home_dir() / "Library/Application Support"; }
fs::path dds::user_cache_dir() { return user_home_dir() / "Library/Caches"; }
fs::path dds::user_config_dir() { return user_home_dir() / "Library/Preferences"; }
fs::path dds::user_data_dir() {
static auto ret = []() -> fs::path {
return fs::absolute(dds::getenv("XDG_DATA_HOME", [] {
return user_home_dir() / "Library/Application Support";
}));
}();
return ret;
}

fs::path dds::user_cache_dir() {
static auto ret = []() -> fs::path {
return fs::absolute(
dds::getenv("XDG_CACHE_HOME", [] { return user_home_dir() / "Library/Caches"; }));
}();
return ret;
}

fs::path dds::user_config_dir() {
static auto ret = []() -> fs::path {
return fs::absolute(
dds::getenv("XDG_CONFIG_HOME", [] { return user_home_dir() / "Library/Preferences"; }));
}();
return ret;
}

#endif

正在加载...
取消
保存