2016-06-27 01:53:10 +02:00
|
|
|
#include "LocalStateDir.h"
|
|
|
|
#include <cpp-utils/system/homedir.h>
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
|
|
|
namespace cryfs {
|
2017-09-28 08:41:08 +02:00
|
|
|
namespace {
|
2017-09-30 10:03:19 +02:00
|
|
|
bf::path appDir() {
|
|
|
|
return cpputils::system::HomeDirectory::get() / ".cryfs";
|
2017-09-28 08:41:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 01:53:10 +02:00
|
|
|
bf::path LocalStateDir::forFilesystemId(const CryConfig::FilesystemID &filesystemId) {
|
2017-09-28 09:19:30 +02:00
|
|
|
_createDirIfNotExists(appDir());
|
|
|
|
bf::path filesystems_dir = appDir() / "filesystems";
|
|
|
|
_createDirIfNotExists(filesystems_dir);
|
|
|
|
bf::path this_filesystem_dir = filesystems_dir / filesystemId.ToString();
|
|
|
|
_createDirIfNotExists(this_filesystem_dir);
|
|
|
|
return this_filesystem_dir;
|
2016-06-27 01:53:10 +02:00
|
|
|
}
|
|
|
|
|
2017-09-28 09:19:30 +02:00
|
|
|
bf::path LocalStateDir::forBasedirMetadata() {
|
|
|
|
_createDirIfNotExists(appDir());
|
|
|
|
return appDir() / "basedirs";
|
2017-09-28 08:41:08 +02:00
|
|
|
}
|
|
|
|
|
2016-06-27 01:53:10 +02:00
|
|
|
void LocalStateDir::_createDirIfNotExists(const bf::path &path) {
|
|
|
|
if (!bf::exists(path)) {
|
2017-09-28 08:41:08 +02:00
|
|
|
bf::create_directories(path);
|
2016-06-27 01:53:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|