-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCopyFile.cpp
39 lines (29 loc) · 918 Bytes
/
CopyFile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "CopyFile.h"
#include "CopyOpenFile.h"
#include "CopyDevice.h"
#include "messmer/fspp/fuse/FuseErrnoException.h"
#include <messmer/cpp-utils/assert/assert.h>
namespace bf = boost::filesystem;
//TODO Get rid of this in favor of exception hierarchy
using fspp::fuse::CHECK_RETVAL;
using cpputils::unique_ref;
using cpputils::make_unique_ref;
namespace copyfs {
CopyFile::CopyFile(CopyDevice *device, const bf::path &path)
:CopyNode(device, path) {
ASSERT(bf::is_regular_file(base_path()), "Path isn't a valid file");
}
CopyFile::~CopyFile() {
}
unique_ref<fspp::OpenFile> CopyFile::open(int flags) const {
return make_unique_ref<CopyOpenFile>(device(), path(), flags);
}
void CopyFile::truncate(off_t size) const {
int retval = ::truncate(base_path().c_str(), size);
CHECK_RETVAL(retval);
}
void CopyFile::remove() {
int retval = ::unlink(base_path().c_str());
CHECK_RETVAL(retval);
}
}