Browse Source

Add block file naming helper, BlockFilePath()

miguelfreitas
Jeff Garzik 12 years ago committed by Jeff Garzik
parent
commit
42613c97d5
  1. 8
      src/main.cpp

8
src/main.cpp

@ -1991,11 +1991,17 @@ bool CheckDiskSpace(uint64 nAdditionalBytes)
return true; return true;
} }
static filesystem::path BlockFilePath(unsigned int nFile)
{
string strBlockFn = strprintf("blk%04d.dat", nFile);
return GetDataDir() / strBlockFn;
}
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode) FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode)
{ {
if ((nFile < 1) || (nFile == (unsigned int) -1)) if ((nFile < 1) || (nFile == (unsigned int) -1))
return NULL; return NULL;
FILE* file = fopen((GetDataDir() / strprintf("blk%04d.dat", nFile)).string().c_str(), pszMode); FILE* file = fopen(BlockFilePath(nFile).string().c_str(), pszMode);
if (!file) if (!file)
return NULL; return NULL;
if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w')) if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w'))

Loading…
Cancel
Save