libcryfs/src/filesystem/CryOpenFile.cpp

66 lines
1.5 KiB
C++
Raw Normal View History

#include "CryOpenFile.h"
#include <sys/types.h>
#include <fcntl.h>
#include "CryDevice.h"
2015-02-17 01:02:15 +01:00
#include "messmer/fspp/fuse/FuseErrnoException.h"
namespace bf = boost::filesystem;
using cpputils::unique_ref;
using cryfs::parallelaccessfsblobstore::FileBlobRef;
//TODO Get rid of this in favor of a exception hierarchy
using fspp::fuse::CHECK_RETVAL;
2014-12-07 08:57:23 +01:00
using fspp::fuse::FuseErrnoException;
namespace cryfs {
CryOpenFile::CryOpenFile(const CryDevice *device, unique_ref<FileBlobRef> fileBlob)
: _device(device), _fileBlob(std::move(fileBlob)) {
}
CryOpenFile::~CryOpenFile() {
2014-12-07 08:57:23 +01:00
//TODO
}
2014-11-21 01:11:24 +01:00
void CryOpenFile::flush() {
_device->callFsActionCallbacks();
2015-04-09 23:42:04 +02:00
_fileBlob->flush();
2014-11-21 01:11:24 +01:00
}
void CryOpenFile::stat(struct ::stat *result) const {
_device->callFsActionCallbacks();
result->st_mode = S_IFREG | S_IRUSR | S_IXUSR | S_IWUSR;
2015-03-11 00:34:25 +01:00
result->st_size = _fileBlob->size();
return;
}
void CryOpenFile::truncate(off_t size) const {
_device->callFsActionCallbacks();
_fileBlob->resize(size);
}
2015-12-07 12:14:06 +01:00
size_t CryOpenFile::read(void *buf, size_t count, off_t offset) const {
_device->callFsActionCallbacks();
2015-03-11 01:05:37 +01:00
return _fileBlob->read(buf, offset, count);
}
void CryOpenFile::write(const void *buf, size_t count, off_t offset) {
_device->callFsActionCallbacks();
_fileBlob->write(buf, offset, count);
}
void CryOpenFile::fsync() {
_device->callFsActionCallbacks();
2015-03-11 00:34:25 +01:00
//throw FuseErrnoException(ENOTSUP);
}
void CryOpenFile::fdatasync() {
_device->callFsActionCallbacks();
2015-03-11 00:34:25 +01:00
//throw FuseErrnoException(ENOTSUP);
}
2014-12-07 08:57:23 +01:00
}