libcryfs/test/fuse/openFile/testutils/FuseOpenTest.cpp

29 lines
611 B
C++
Raw Normal View History

2014-11-20 21:23:35 +01:00
#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;
}
}
2014-11-20 21:23:35 +01:00
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;
}
2014-11-20 21:23:35 +01:00
}