MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / OpenDiskFile

Function OpenDiskFile

src/main.cpp:3776–3797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3774}
3775
3776FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
3777{
3778 if (pos.IsNull())
3779 return NULL;
3780 boost::filesystem::path path = GetBlockPosFilename(pos, prefix);
3781 boost::filesystem::create_directories(path.parent_path());
3782 FILE* file = fopen(path.string().c_str(), "rb+");
3783 if (!file && !fReadOnly)
3784 file = fopen(path.string().c_str(), "wb+");
3785 if (!file) {
3786 LogPrintf("Unable to open file %s\n", path.string());
3787 return NULL;
3788 }
3789 if (pos.nPos) {
3790 if (fseek(file, pos.nPos, SEEK_SET)) {
3791 LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string());
3792 fclose(file);
3793 return NULL;
3794 }
3795 }
3796 return file;
3797}
3798
3799FILE* OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly) {
3800 return OpenDiskFile(pos, "blk", fReadOnly);

Callers 2

OpenBlockFileFunction · 0.85
OpenUndoFileFunction · 0.85

Calls 2

GetBlockPosFilenameFunction · 0.85
IsNullMethod · 0.45

Tested by

no test coverage detected