Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,297 Lines • ▼ Show 20 Lines | |||||
static FILE *OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, | static FILE *OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, | ||||
bool fReadOnly) { | bool fReadOnly) { | ||||
if (pos.IsNull()) { | if (pos.IsNull()) { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
fs::path path = GetBlockPosFilename(pos, prefix); | fs::path path = GetBlockPosFilename(pos, prefix); | ||||
fs::create_directories(path.parent_path()); | fs::create_directories(path.parent_path()); | ||||
FILE *file = fsbridge::fopen(path, "rb+"); | FILE *file = fsbridge::fopen(path, fReadOnly ? "rb" : "rb+"); | ||||
if (!file && !fReadOnly) { | if (!file && !fReadOnly) { | ||||
file = fsbridge::fopen(path, "wb+"); | file = fsbridge::fopen(path, "wb+"); | ||||
} | } | ||||
if (!file) { | if (!file) { | ||||
LogPrintf("Unable to open file %s\n", path.string()); | LogPrintf("Unable to open file %s\n", path.string()); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,348 Lines • Show Last 20 Lines |