mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
replace custom GetFilesize() with boost::filesystem::file_size()
This commit is contained in:
parent
aefbf6e30c
commit
a486abd419
@ -27,6 +27,8 @@
|
|||||||
#include <miniupnpc/upnperrors.h>
|
#include <miniupnpc/upnperrors.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
// Dump addresses to peers.dat every 15 minutes (900s)
|
// Dump addresses to peers.dat every 15 minutes (900s)
|
||||||
#define DUMP_ADDRESSES_INTERVAL 900
|
#define DUMP_ADDRESSES_INTERVAL 900
|
||||||
|
|
||||||
@ -1986,7 +1988,7 @@ bool CAddrDB::Read(CAddrMan& addr)
|
|||||||
return error("CAddrman::Read() : open failed");
|
return error("CAddrman::Read() : open failed");
|
||||||
|
|
||||||
// use file size to size memory buffer
|
// use file size to size memory buffer
|
||||||
int fileSize = GetFilesize(filein);
|
int fileSize = boost::filesystem::file_size(pathAddr);
|
||||||
int dataSize = fileSize - sizeof(uint256);
|
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;
|
if ( dataSize < 0 ) dataSize = 0;
|
||||||
|
19
src/util.cpp
19
src/util.cpp
@ -1107,16 +1107,6 @@ void FileCommit(FILE *fileout)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TruncateFile(FILE *file, unsigned int length) {
|
bool TruncateFile(FILE *file, unsigned int length) {
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
return _chsize(_fileno(file), length) == 0;
|
return _chsize(_fileno(file), length) == 0;
|
||||||
@ -1195,7 +1185,7 @@ void ShrinkDebugFile()
|
|||||||
// Scroll debug.log if it's getting too big
|
// Scroll debug.log if it's getting too big
|
||||||
boost::filesystem::path pathLog = GetDataDir() / "debug.log";
|
boost::filesystem::path pathLog = GetDataDir() / "debug.log";
|
||||||
FILE* file = fopen(pathLog.string().c_str(), "r");
|
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
|
// Restart the file with some of the end
|
||||||
char pch[200000];
|
char pch[200000];
|
||||||
@ -1214,13 +1204,6 @@ void ShrinkDebugFile()
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// "Never go to sea with two chronometers; take one or three."
|
// "Never go to sea with two chronometers; take one or three."
|
||||||
// Our three time sources are:
|
// Our three time sources are:
|
||||||
|
@ -185,7 +185,6 @@ void ParseParameters(int argc, const char*const argv[]);
|
|||||||
bool WildcardMatch(const char* psz, const char* mask);
|
bool WildcardMatch(const char* psz, const char* mask);
|
||||||
bool WildcardMatch(const std::string& str, const std::string& mask);
|
bool WildcardMatch(const std::string& str, const std::string& mask);
|
||||||
void FileCommit(FILE *fileout);
|
void FileCommit(FILE *fileout);
|
||||||
int GetFilesize(FILE* file);
|
|
||||||
bool TruncateFile(FILE *file, unsigned int length);
|
bool TruncateFile(FILE *file, unsigned int length);
|
||||||
int RaiseFileDescriptorLimit(int nMinFD);
|
int RaiseFileDescriptorLimit(int nMinFD);
|
||||||
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
|
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
|
||||||
|
Loading…
Reference in New Issue
Block a user