mirror of https://github.com/libAthena/athena.git
* Change Athena::utility::fileSize to use stat64 instead of ftello
* Fix output of ftello64 in win32_largefilewrapper
This commit is contained in:
parent
be135d1caa
commit
f322f1d7e7
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue