MCPcopy Create free account
hub / github.com/ElementsProject/elements / Open

Method Open

src/flatfile.cpp:33–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool read_only)
34{
35 if (pos.IsNull()) {
36 return nullptr;
37 }
38 fs::path path = FileName(pos);
39 fs::create_directories(path.parent_path());
40 FILE* file = fsbridge::fopen(path, read_only ? "rb": "rb+");
41 if (!file && !read_only)
42 file = fsbridge::fopen(path, "wb+");
43 if (!file) {
44 LogPrintf("Unable to open file %s\n", fs::PathToString(path));
45 return nullptr;
46 }
47 if (pos.nPos && fseek(file, pos.nPos, SEEK_SET)) {
48 LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, fs::PathToString(path));
49 fclose(file);
50 return nullptr;
51 }
52 return file;
53}
54
55size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_of_space)
56{

Callers

nothing calls this directly

Calls 4

create_directoriesFunction · 0.85
fopenFunction · 0.85
PathToStringFunction · 0.85
IsNullMethod · 0.45

Tested by

no test coverage detected