2014-11-15 16:33:24 +01:00
|
|
|
#include "CryDevice.h"
|
|
|
|
|
|
|
|
#include "CryDir.h"
|
|
|
|
#include "CryFile.h"
|
|
|
|
|
2014-11-28 14:46:45 +01:00
|
|
|
#include "fspp/fuse/FuseErrnoException.h"
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
|
|
|
|
//TODO Get rid of this in favor of exception hierarchy
|
2014-11-28 14:46:45 +01:00
|
|
|
using fspp::fuse::CHECK_RETVAL;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
|
|
|
CryDevice::CryDevice(const bf::path &root_path): _root_path(root_path) {
|
|
|
|
}
|
|
|
|
|
|
|
|
CryDevice::~CryDevice() {
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
unique_ptr<fspp::Node> CryDevice::Load(const bf::path &path) {
|
2014-11-15 16:33:24 +01:00
|
|
|
auto real_path = RootDir() / path;
|
|
|
|
if(bf::is_directory(real_path)) {
|
|
|
|
return make_unique<CryDir>(this, path);
|
|
|
|
} else if(bf::is_regular_file(real_path)) {
|
|
|
|
return make_unique<CryFile>(this, path);
|
|
|
|
}
|
|
|
|
|
2014-11-28 14:46:45 +01:00
|
|
|
throw fspp::fuse::FuseErrnoException(ENOENT);
|
2014-11-15 16:33:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CryDevice::statfs(const bf::path &path, struct statvfs *fsstat) {
|
|
|
|
auto real_path = RootDir() / path;
|
|
|
|
int retval = ::statvfs(real_path.c_str(), fsstat);
|
|
|
|
CHECK_RETVAL(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace cryfs */
|