| 33 | } |
| 34 | |
| 35 | FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool read_only) const |
| 36 | { |
| 37 | if (pos.IsNull()) { |
| 38 | return nullptr; |
| 39 | } |
| 40 | fs::path path = FileName(pos); |
| 41 | fs::create_directories(path.parent_path()); |
| 42 | FILE* file = fsbridge::fopen(path, read_only ? "rb": "rb+"); |
| 43 | if (!file && !read_only) |
| 44 | file = fsbridge::fopen(path, "wb+"); |
| 45 | if (!file) { |
| 46 | LogError("Unable to open file %s", fs::PathToString(path)); |
| 47 | return nullptr; |
| 48 | } |
| 49 | if (pos.nPos && fseek(file, pos.nPos, SEEK_SET)) { |
| 50 | LogError("Unable to seek to position %u of %s", pos.nPos, fs::PathToString(path)); |
| 51 | if (fclose(file) != 0) { |
| 52 | LogError("Unable to close file %s", fs::PathToString(path)); |
| 53 | } |
| 54 | return nullptr; |
| 55 | } |
| 56 | return file; |
| 57 | } |
| 58 | |
| 59 | size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_of_space) const |
| 60 | { |
nothing calls this directly
no test coverage detected