2014-11-15 16:33:24 +01:00
|
|
|
#include "CryFile.h"
|
|
|
|
|
|
|
|
#include "CryDevice.h"
|
|
|
|
#include "CryOpenFile.h"
|
2014-11-15 17:24:07 +01:00
|
|
|
#include "fusepp/impl/FuseErrnoException.h"
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
|
|
|
//TODO Get rid of this in favor of exception hierarchy
|
2014-11-16 00:05:28 +01:00
|
|
|
using fspp::CHECK_RETVAL;
|
2014-11-15 16:33:24 +01:00
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
|
|
|
CryFile::CryFile(CryDevice *device, const bf::path &path)
|
|
|
|
:CryNode(device, path) {
|
|
|
|
assert(bf::is_regular_file(base_path()));
|
|
|
|
}
|
|
|
|
|
|
|
|
CryFile::~CryFile() {
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:05:28 +01:00
|
|
|
unique_ptr<fspp::OpenFile> CryFile::open(int flags) const {
|
2014-11-15 16:33:24 +01:00
|
|
|
return make_unique<CryOpenFile>(device(), path(), flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CryFile::truncate(off_t size) const {
|
|
|
|
int retval = ::truncate(base_path().c_str(), size);
|
|
|
|
CHECK_RETVAL(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CryFile::unlink() {
|
|
|
|
int retval = ::unlink(base_path().c_str());
|
|
|
|
CHECK_RETVAL(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace cryfs */
|