2016-06-27 01:53:10 +02:00
|
|
|
#include "LocalStateDir.h"
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
|
|
|
namespace cryfs {
|
2018-04-22 07:04:21 +02:00
|
|
|
LocalStateDir::LocalStateDir(bf::path appDir): _appDir(std::move(appDir)) {}
|
2017-09-28 08:41:08 +02:00
|
|
|
|
2018-04-22 07:04:21 +02:00
|
|
|
bf::path LocalStateDir::forFilesystemId(const CryConfig::FilesystemID &filesystemId) const {
|
|
|
|
_createDirIfNotExists(_appDir);
|
|
|
|
bf::path filesystems_dir = _appDir / "filesystems";
|
2017-09-28 09:19:30 +02:00
|
|
|
_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
|
|
|
}
|
|
|
|
|
2018-04-22 07:04:21 +02:00
|
|
|
bf::path LocalStateDir::forBasedirMetadata() const {
|
|
|
|
_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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|