This commit is contained in:
jl777
2018-04-13 17:46:08 +03:00
parent 6a98bf0618
commit f527fcdb97
2 changed files with 24 additions and 3 deletions

View File

@@ -4037,6 +4037,7 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes)
FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
{
int32_t incr;
if (pos.IsNull())
return NULL;
boost::filesystem::path path = GetBlockPosFilename(pos, prefix);
@@ -4048,6 +4049,26 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
LogPrintf("Unable to open file %s\n", path.string());
return NULL;
}
if ( strcmp(prefix,(char *)"blk") == 0 )
{
long fsize,fpos; int32_t incr = 16*1024*1024;
fpos = ftell(file);
fseek(file,0,SEEK_END);
fsize = ftell(file);
if ( fsize > incr )
{
char *ignore = malloc(incr);
if ( ignore != 0 )
{
rewind(file);
while ( fread(ignore,1,incr,file) == incr )
fprintf(stderr,".");
free(ignore);
fprintf(stderr,"loaded %ld bytes set fpos.%ld\n",(long)ftell(file),(long)fpos);
}
}
fseek(file,fpos,SEEK_SET);
}
if (pos.nPos) {
if (fseek(file, pos.nPos, SEEK_SET)) {
LogPrintf("Unable to seek to position %u of %s\n", pos.nPos, path.string());