| 31 | } |
| 32 | |
| 33 | FILE* 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 | |
| 55 | size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_of_space) |
| 56 | { |
nothing calls this directly
no test coverage detected