Added native wstring fileSize method for Win32

This commit is contained in:
Jack Andersen 2015-11-30 14:34:26 -10:00
parent 3dbc746ddd
commit 87013ab673
4 changed files with 12 additions and 8 deletions

View File

@ -208,6 +208,9 @@ std::string& rtrim(std::string& s);
// trim from both ends
std::string& trim(std::string& s);
atUint64 fileSize(const std::string& filename);
#ifdef _MSC_VER
atUint64 fileSize(const std::wstring& filename);
#endif
std::string wideToUtf8(const std::wstring& src);

View File

@ -155,11 +155,7 @@ atUint64 FileReader::length() const
return 0;
}
#if _WIN32
return utility::fileSize(utility::wideToUtf8(m_filename));
#else
return utility::fileSize(m_filename);
#endif
}
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len)

View File

@ -111,11 +111,7 @@ atUint64 FileWriter::position() const
atUint64 FileWriter::length() const
{
#if _WIN32
return utility::fileSize(utility::wideToUtf8(m_filename));
#else
return utility::fileSize(m_filename);
#endif
}
void FileWriter::writeUBytes(const atUint8* data, atUint64 len)

View File

@ -171,6 +171,15 @@ atUint64 fileSize(const std::string& filename)
return st.st_size;
}
#ifdef _MSC_VER
atUint64 fileSize(const std::wstring& filename)
{
stat64_t st;
_wstati64(filename.c_str(), &st);
return st.st_size;
}
#endif
// trim from both ends
std::string& trim(std::string& s)
{