File: FuseCreateAndOpenTest.cpp

package info (click to toggle)
cryfs 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 28,404 kB
  • sloc: cpp: 150,188; asm: 10,493; python: 1,455; javascript: 65; sh: 50; makefile: 17; xml: 7
file content (24 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "FuseCreateAndOpenTest.h"

using cpputils::unique_ref;
using cpputils::make_unique_ref;

void FuseCreateAndOpenTest::CreateAndOpenFile(const std::string &filename, int flags) {
    auto fs = TestFS();

    auto fd = CreateAndOpenFileAllowErrors(fs.get(), filename, flags);
    EXPECT_GE(fd->fd(), 0) << "Opening file failed";
}

int FuseCreateAndOpenTest::CreateAndOpenFileReturnError(const std::string &filename, int flags) {
    auto fs = TestFS();

    auto fd = CreateAndOpenFileAllowErrors(fs.get(), filename, flags);
    return fd->errorcode();
}

unique_ref<OpenFileHandle> FuseCreateAndOpenTest::CreateAndOpenFileAllowErrors(const TempTestFS *fs, const std::string &filename, int flags) {
    auto real_path = fs->mountDir() / filename;
    auto fd = make_unique_ref<OpenFileHandle>(real_path.string().c_str(), flags | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
    return fd;
}