2014-11-20 21:23:35 +01:00
|
|
|
#include "FuseOpenTest.h"
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
using cpputils::unique_ref;
|
|
|
|
using cpputils::make_unique_ref;
|
2014-11-20 21:23:35 +01:00
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
void FuseOpenTest::OpenFile(const char *filename, int flags) {
|
|
|
|
auto fs = TestFS();
|
|
|
|
auto fd = OpenFileAllowError(fs.get(), filename, flags);
|
|
|
|
EXPECT_GE(fd->fd(), 0);
|
2014-12-06 15:33:01 +01:00
|
|
|
}
|
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
int FuseOpenTest::OpenFileReturnError(const char *filename, int flags) {
|
2014-11-20 21:23:35 +01:00
|
|
|
auto fs = TestFS();
|
2017-08-25 01:14:16 +02:00
|
|
|
auto fd = OpenFileAllowError(fs.get(), filename, flags);
|
|
|
|
return fd->errorcode();
|
|
|
|
}
|
2014-11-20 21:23:35 +01:00
|
|
|
|
2017-08-25 01:14:16 +02:00
|
|
|
unique_ref<OpenFileHandle> FuseOpenTest::OpenFileAllowError(const TempTestFS *fs, const char *filename, int flags) {
|
2014-11-20 21:23:35 +01:00
|
|
|
auto realpath = fs->mountDir() / filename;
|
2018-05-21 01:20:38 +02:00
|
|
|
return make_unique_ref<OpenFileHandle>(realpath.string().c_str(), flags);
|
2014-11-20 21:23:35 +01:00
|
|
|
}
|