* Change Athena::utility::fileSize to use stat64 instead of ftello

* Fix output of ftello64 in win32_largefilewrapper
This commit is contained in:
Antidote 2014-12-28 14:38:55 -08:00
parent be135d1caa
commit f322f1d7e7
6 changed files with 10 additions and 11 deletions

View File

@ -74,7 +74,7 @@ std::string &rtrim(std::string &s);
// trim from both ends
std::string &trim(std::string &s);
atUint64 fileSize(FILE* f);
atUint64 fileSize(const std::string& filename);
} // utility
} // Athena
#endif

View File

@ -7,7 +7,7 @@
extern "C" {
#endif
int fseeko64(FILE* fp, off64_t offset, int whence);
int ftello64(FILE* fp);
off64_t ftello64(FILE* fp);
#ifdef __cplusplus
}
#endif

View File

@ -119,7 +119,7 @@ atUint64 FileReader::length() const
if (!isOpen())
THROW_INVALID_OPERATION_EXCEPTION("File not open");
return utility::fileSize(m_fileHandle);
return utility::fileSize(m_filename);
}
void FileReader::seekBit(int bit)

View File

@ -109,7 +109,7 @@ atUint64 FileWriter::position() const
atUint64 FileWriter::length() const
{
return utility::fileSize(m_fileHandle);
return utility::fileSize(m_filename);
}
void FileWriter::writeBit(bool val)

View File

@ -22,6 +22,7 @@
#include <cstdarg>
#include <iterator>
#include <cstdio>
#include <sys/stat.h>
namespace Athena
{
@ -365,13 +366,11 @@ int countChar(const std::string& str, const char chr, int* lastOccur)
return ret;
}
atUint64 fileSize(FILE* f)
atUint64 fileSize(const std::string& filename)
{
atUint64 oldPos = ftello64(f);
fseeko64(f, 0, SEEK_END);
atUint64 size = ftello64(f);
fseeko64(f, oldPos, SEEK_SET);
return size;
struct stat64 st;
stat64(filename.c_str(), &st);
return st.st_size;
}
std::string& ltrim(std::string& s)

View File

@ -7,7 +7,7 @@ int fseeko64(FILE* fp, off64_t offset, int whence)
return _fseeki64(fp, offset, whence);
}
int ftello64(FILE* fp)
off64_t ftello64(FILE* fp)
{
return _ftelli64(fp);
}