aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2014-01-30 10:55:55 +0100
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2014-03-03 22:33:09 +0100
commita486abd419d76ec3aec4adb90216eccb7b4be0c4 (patch)
tree371c743e3a4fea997da977c05275e728c66f1900 /src
parentaefbf6e30cadaf77ebee44284c74cc5449dc173f (diff)
replace custom GetFilesize() with boost::filesystem::file_size()
Diffstat (limited to 'src')
-rw-r--r--src/net.cpp6
-rw-r--r--src/util.cpp19
-rw-r--r--src/util.h1
3 files changed, 5 insertions, 21 deletions
diff --git a/src/net.cpp b/src/net.cpp
index bb1d1bac45..d3d276eb59 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -27,6 +27,8 @@
#include <miniupnpc/upnperrors.h>
#endif
+#include <boost/filesystem.hpp>
+
// Dump addresses to peers.dat every 15 minutes (900s)
#define DUMP_ADDRESSES_INTERVAL 900
@@ -1986,9 +1988,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);
diff --git a/src/util.cpp b/src/util.cpp
index 36dfd8ab79..b90921ab83 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1107,16 +1107,6 @@ void FileCommit(FILE *fileout)
#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) {
#if defined(WIN32)
return _chsize(_fileno(file), length) == 0;
@@ -1195,7 +1185,7 @@ 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];
@@ -1214,13 +1204,6 @@ void ShrinkDebugFile()
fclose(file);
}
-
-
-
-
-
-
-
//
// "Never go to sea with two chronometers; take one or three."
// Our three time sources are:
diff --git a/src/util.h b/src/util.h
index 32bc050369..b0dabd2f67 100644
--- a/src/util.h
+++ b/src/util.h
@@ -185,7 +185,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 TruncateFile(FILE *file, unsigned int length);
int RaiseFileDescriptorLimit(int nMinFD);
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);