Use XDG instead of /home/heinzi/.cryfs to store integrity data

This commit is contained in:
Sebastian Messmer 2018-05-01 23:54:30 -07:00
parent 04bf27402f
commit b97da2c735
3 changed files with 12 additions and 1 deletions

View File

@ -36,6 +36,15 @@ namespace cpputils {
return homedir;
}
bf::path HomeDirectory::getXDGDataDir() {
const char* xdg_data_dir = std::getenv("XDG_DATA_HOME");
if (xdg_data_dir != nullptr) {
return xdg_data_dir;
}
return cpputils::system::HomeDirectory::get() / ".local" / "share";
}
FakeHomeDirectoryRAII::FakeHomeDirectoryRAII(const boost::filesystem::path &fakeHomeDirectory)
:_oldHomeDirectory(HomeDirectory::singleton()._home_directory) {
HomeDirectory::singleton()._home_directory = fakeHomeDirectory;

View File

@ -15,6 +15,8 @@ namespace cpputils {
public:
static const boost::filesystem::path &get();
static boost::filesystem::path getXDGDataDir();
private:
boost::filesystem::path _home_directory;

View File

@ -22,7 +22,7 @@ namespace cryfs {
}
const bf::path& Environment::defaultLocalStateDir() {
static const bf::path value = cpputils::system::HomeDirectory::get() / ".cryfs";
static const bf::path value = cpputils::system::HomeDirectory::getXDGDataDir() / "cryfs";
return value;
}