File tree Expand file tree Collapse file tree 3 files changed +5
-21
lines changed Expand file tree Collapse file tree 3 files changed +5
-21
lines changed Original file line number Diff line number Diff line change 27
27
#include < miniupnpc/upnperrors.h>
28
28
#endif
29
29
30
+ #include < boost/filesystem.hpp>
31
+
30
32
// Dump addresses to peers.dat every 15 minutes (900s)
31
33
#define DUMP_ADDRESSES_INTERVAL 900
32
34
@@ -1986,9 +1988,9 @@ bool CAddrDB::Read(CAddrMan& addr)
1986
1988
return error (" CAddrman::Read() : open failed" );
1987
1989
1988
1990
// use file size to size memory buffer
1989
- int fileSize = GetFilesize (filein );
1991
+ int fileSize = boost::filesystem::file_size (pathAddr );
1990
1992
int dataSize = fileSize - sizeof (uint256);
1991
- // Don't try to resize to a negative number if file is small
1993
+ // Don't try to resize to a negative number if file is small
1992
1994
if ( dataSize < 0 ) dataSize = 0 ;
1993
1995
vector<unsigned char > vchData;
1994
1996
vchData.resize (dataSize);
Original file line number Diff line number Diff line change @@ -1107,16 +1107,6 @@ void FileCommit(FILE *fileout)
1107
1107
#endif
1108
1108
}
1109
1109
1110
- int GetFilesize (FILE* file)
1111
- {
1112
- int nSavePos = ftell (file);
1113
- int nFilesize = -1 ;
1114
- if (fseek (file, 0 , SEEK_END) == 0 )
1115
- nFilesize = ftell (file);
1116
- fseek (file, nSavePos, SEEK_SET);
1117
- return nFilesize;
1118
- }
1119
-
1120
1110
bool TruncateFile (FILE *file, unsigned int length) {
1121
1111
#if defined(WIN32)
1122
1112
return _chsize (_fileno (file), length) == 0 ;
@@ -1195,7 +1185,7 @@ void ShrinkDebugFile()
1195
1185
// Scroll debug.log if it's getting too big
1196
1186
boost::filesystem::path pathLog = GetDataDir () / " debug.log" ;
1197
1187
FILE* file = fopen (pathLog.string ().c_str (), " r" );
1198
- if (file && GetFilesize (file ) > 10 * 1000000 )
1188
+ if (file && boost::filesystem::file_size (pathLog ) > 10 * 1000000 )
1199
1189
{
1200
1190
// Restart the file with some of the end
1201
1191
char pch[200000 ];
@@ -1214,13 +1204,6 @@ void ShrinkDebugFile()
1214
1204
fclose (file);
1215
1205
}
1216
1206
1217
-
1218
-
1219
-
1220
-
1221
-
1222
-
1223
-
1224
1207
//
1225
1208
// "Never go to sea with two chronometers; take one or three."
1226
1209
// Our three time sources are:
Original file line number Diff line number Diff line change @@ -185,7 +185,6 @@ void ParseParameters(int argc, const char*const argv[]);
185
185
bool WildcardMatch (const char * psz, const char * mask);
186
186
bool WildcardMatch (const std::string& str, const std::string& mask);
187
187
void FileCommit (FILE *fileout);
188
- int GetFilesize (FILE* file);
189
188
bool TruncateFile (FILE *file, unsigned int length);
190
189
int RaiseFileDescriptorLimit (int nMinFD);
191
190
void AllocateFileRange (FILE *file, unsigned int offset, unsigned int length);
You can’t perform that action at this time.
0 commit comments