MCPcopy Create free account
hub / github.com/LUX-Core/lux / OpenDiskFile

Function OpenDiskFile

src/main.cpp:5323–5344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5321}
5322
5323FILE* OpenDiskFile(const CDiskBlockPos& pos, const char* prefix, bool fReadOnly)
5324{
5325 if (pos.IsNull())
5326 return NULL;
5327 boost::filesystem::path path = GetBlockPosFilename(pos, prefix);
5328 boost::filesystem::create_directories(path.parent_path());
5329 FILE* file = fopen(path.string().c_str(), "rb+");
5330 if (!file && !fReadOnly)
5331 file = fopen(path.string().c_str(), "wb+");
5332 if (!file) {
5333 LogPrintf("Unable to open file %s\n", path.string());
5334 return NULL;
5335 }
5336 if (pos.nPos) {
5337 if (fseek(file, pos.nPos, SEEK_SET)) {
5338 LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string());
5339 fclose(file);
5340 return NULL;
5341 }
5342 }
5343 return file;
5344}
5345
5346FILE* OpenBlockFile(const CDiskBlockPos& pos, bool fReadOnly)
5347{

Callers 2

OpenBlockFileFunction · 0.85
OpenUndoFileFunction · 0.85

Calls 2

GetBlockPosFilenameFunction · 0.85
IsNullMethod · 0.45

Tested by

no test coverage detected