mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
replace custom GetFilesize() with boost::filesystem::file_size()
This commit is contained in:
parent
aefbf6e30c
commit
a486abd419
3 changed files with 5 additions and 21 deletions
19
src/util.cpp
19
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue