libcryfs/test/fuse/openFile/testutils/FuseOpenTest.cpp
2015-02-17 00:48:49 +01:00

29 lines
611 B
C++

#include "FuseOpenTest.h"
int FuseOpenTest::OpenFile(const char *filename, int flags) {
int fd = OpenFileAllowError(filename, flags);
EXPECT_GE(fd, 0);
return fd;
}
int FuseOpenTest::OpenFileReturnError(const char *filename, int flags) {
int fd = OpenFileAllowError(filename, flags);
if (fd >= 0) {
return 0;
} else {
return -fd;
}
}
int FuseOpenTest::OpenFileAllowError(const char *filename, int flags) {
auto fs = TestFS();
auto realpath = fs->mountDir() / filename;
int fd = ::open(realpath.c_str(), flags);
if (fd >= 0) {
return fd;
} else {
return -errno;
}
}