@@ -3769,29 +3769,6 @@ static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfte
37693769 nLastBlockWeCanPrune, count);
37703770}
37713771
3772- static FILE* OpenDiskFile (const CDiskBlockPos &pos, const char *prefix, bool fReadOnly )
3773- {
3774- if (pos.IsNull ())
3775- return nullptr ;
3776- fs::path path = GetBlockPosFilename (pos, prefix);
3777- fs::create_directories (path.parent_path ());
3778- FILE* file = fsbridge::fopen (path, fReadOnly ? " rb" : " rb+" );
3779- if (!file && !fReadOnly )
3780- file = fsbridge::fopen (path, " wb+" );
3781- if (!file) {
3782- LogPrintf (" Unable to open file %s\n " , path.string ());
3783- return nullptr ;
3784- }
3785- if (pos.nPos ) {
3786- if (fseek (file, pos.nPos , SEEK_SET)) {
3787- LogPrintf (" Unable to seek to position %u of %s\n " , pos.nPos , path.string ());
3788- fclose (file);
3789- return nullptr ;
3790- }
3791- }
3792- return file;
3793- }
3794-
37953772static FlatFileSeq BlockFileSeq ()
37963773{
37973774 return FlatFileSeq (GetBlocksDir (), " blk" , BLOCKFILE_CHUNK_SIZE);
@@ -3803,12 +3780,12 @@ static FlatFileSeq UndoFileSeq()
38033780}
38043781
38053782FILE* OpenBlockFile (const CDiskBlockPos &pos, bool fReadOnly ) {
3806- return OpenDiskFile ( pos, " blk " , fReadOnly );
3783+ return BlockFileSeq (). Open ( pos, fReadOnly );
38073784}
38083785
38093786/* * Open an undo file (rev?????.dat) */
38103787static FILE* OpenUndoFile (const CDiskBlockPos &pos, bool fReadOnly ) {
3811- return OpenDiskFile ( pos, " rev " , fReadOnly );
3788+ return UndoFileSeq (). Open ( pos, fReadOnly );
38123789}
38133790
38143791fs::path GetBlockPosFilename (const CDiskBlockPos &pos)
0 commit comments