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
|
// trim from both ends
|
||||||
std::string &trim(std::string &s);
|
std::string &trim(std::string &s);
|
||||||
atUint64 fileSize(FILE* f);
|
atUint64 fileSize(const std::string& filename);
|
||||||
} // utility
|
} // utility
|
||||||
} // Athena
|
} // Athena
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
int fseeko64(FILE* fp, off64_t offset, int whence);
|
int fseeko64(FILE* fp, off64_t offset, int whence);
|
||||||
int ftello64(FILE* fp);
|
off64_t ftello64(FILE* fp);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -119,7 +119,7 @@ atUint64 FileReader::length() const
|
||||||
if (!isOpen())
|
if (!isOpen())
|
||||||
THROW_INVALID_OPERATION_EXCEPTION("File not open");
|
THROW_INVALID_OPERATION_EXCEPTION("File not open");
|
||||||
|
|
||||||
return utility::fileSize(m_fileHandle);
|
return utility::fileSize(m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileReader::seekBit(int bit)
|
void FileReader::seekBit(int bit)
|
||||||
|
|
|
@ -109,7 +109,7 @@ atUint64 FileWriter::position() const
|
||||||
|
|
||||||
atUint64 FileWriter::length() const
|
atUint64 FileWriter::length() const
|
||||||
{
|
{
|
||||||
return utility::fileSize(m_fileHandle);
|
return utility::fileSize(m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileWriter::writeBit(bool val)
|
void FileWriter::writeBit(bool val)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
namespace Athena
|
namespace Athena
|
||||||
{
|
{
|
||||||
|
@ -365,13 +366,11 @@ int countChar(const std::string& str, const char chr, int* lastOccur)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
atUint64 fileSize(FILE* f)
|
atUint64 fileSize(const std::string& filename)
|
||||||
{
|
{
|
||||||
atUint64 oldPos = ftello64(f);
|
struct stat64 st;
|
||||||
fseeko64(f, 0, SEEK_END);
|
stat64(filename.c_str(), &st);
|
||||||
atUint64 size = ftello64(f);
|
return st.st_size;
|
||||||
fseeko64(f, oldPos, SEEK_SET);
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string& ltrim(std::string& s)
|
std::string& ltrim(std::string& s)
|
||||||
|
|
|
@ -7,7 +7,7 @@ int fseeko64(FILE* fp, off64_t offset, int whence)
|
||||||
return _fseeki64(fp, offset, whence);
|
return _fseeki64(fp, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ftello64(FILE* fp)
|
off64_t ftello64(FILE* fp)
|
||||||
{
|
{
|
||||||
return _ftelli64(fp);
|
return _ftelli64(fp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue