From 87013ab6737d7ad2b35caee7cd2b6d5b73f05251 Mon Sep 17 00:00:00 2001
From: Jack Andersen <jackoalan@gmail.com>
Date: Mon, 30 Nov 2015 14:34:26 -1000
Subject: [PATCH] Added native wstring fileSize method for Win32

---
 include/Athena/Utility.hpp | 3 +++
 src/Athena/FileReader.cpp  | 4 ----
 src/Athena/FileWriter.cpp  | 4 ----
 src/Athena/Utility.cpp     | 9 +++++++++
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/Athena/Utility.hpp b/include/Athena/Utility.hpp
index b629e7e..9702b87 100644
--- a/include/Athena/Utility.hpp
+++ b/include/Athena/Utility.hpp
@@ -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);
 
diff --git a/src/Athena/FileReader.cpp b/src/Athena/FileReader.cpp
index cdb8fc4..b7313bc 100644
--- a/src/Athena/FileReader.cpp
+++ b/src/Athena/FileReader.cpp
@@ -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)
diff --git a/src/Athena/FileWriter.cpp b/src/Athena/FileWriter.cpp
index 0ec537e..caace1f 100644
--- a/src/Athena/FileWriter.cpp
+++ b/src/Athena/FileWriter.cpp
@@ -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)
diff --git a/src/Athena/Utility.cpp b/src/Athena/Utility.cpp
index 81f5568..6851aee 100644
--- a/src/Athena/Utility.cpp
+++ b/src/Athena/Utility.cpp
@@ -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)
 {