Permalink
Browse files

replace custom GetFilesize() with boost::filesystem::file_size()

  • Loading branch information...
Tranz5 committed Jul 12, 2014
1 parent a1943e2 commit b40c7b454690749a0e1e1b96eff0382ad8f60219
Showing with 3 additions and 27 deletions.
  1. +2 −2 src/db.cpp
  2. +1 −18 src/util.cpp
  3. +0 −7 src/util.h
View
@@ -564,9 +564,9 @@ bool CAddrDB::Read(CAddrMan& addr)
return error("CAddrman::Read() : open failed");
// use file size to size memory buffer
int fileSize = GetFilesize(filein);
int fileSize = boost::filesystem::file_size(pathAddr);
int dataSize = fileSize - sizeof(uint256);
//Don't try to resize to a negative number if file is small
// Don't try to resize to a negative number if file is small
if ( dataSize < 0 ) dataSize = 0;
vector<unsigned char> vchData;
vchData.resize(dataSize);
View
@@ -1256,22 +1256,12 @@ void FileCommit(FILE *fileout)
}
int GetFilesize(FILE* file)
{
int nSavePos = ftell(file);
int nFilesize = -1;
if (fseek(file, 0, SEEK_END) == 0)
nFilesize = ftell(file);
fseek(file, nSavePos, SEEK_SET);
return nFilesize;
}
void ShrinkDebugFile()
{
// Scroll debug.log if it's getting too big
boost::filesystem::path pathLog = GetDataDir() / "debug.log";
FILE* file = fopen(pathLog.string().c_str(), "r");
if (file && GetFilesize(file) > 10 * 1000000)
if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000)
{
// Restart the file with some of the end
char pch[200000];
@@ -1288,13 +1278,6 @@ void ShrinkDebugFile()
}
}
//
// "Never go to sea with two chronometers; take one or three."
// Our three time sources are:
View
@@ -133,12 +133,6 @@ inline void Sleep(int64 n)
#endif
extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug;
@@ -213,7 +207,6 @@ void ParseParameters(int argc, const char*const argv[]);
bool WildcardMatch(const char* psz, const char* mask);
bool WildcardMatch(const std::string& str, const std::string& mask);
void FileCommit(FILE *fileout);
int GetFilesize(FILE* file);
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest);
boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);

0 comments on commit b40c7b4

Please sign in to comment.