From a64be126461201c2739efaca733138edcfca8e30 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Tue, 19 Jan 2016 12:36:10 -0800 Subject: [PATCH] added missing getFileSize() method for winrt --- cocos/platform/winrt/CCFileUtilsWinRT.cpp | 13 +++++++++++++ cocos/platform/winrt/CCFileUtilsWinRT.h | 1 + 2 files changed, 14 insertions(+) diff --git a/cocos/platform/winrt/CCFileUtilsWinRT.cpp b/cocos/platform/winrt/CCFileUtilsWinRT.cpp index e6ceec1d90..338f9eba89 100644 --- a/cocos/platform/winrt/CCFileUtilsWinRT.cpp +++ b/cocos/platform/winrt/CCFileUtilsWinRT.cpp @@ -129,6 +129,19 @@ std::string CCFileUtilsWinRT::getSuitableFOpen(const std::string& filenameUtf8) return UTF8StringToMultiByte(filenameUtf8); } +long CCFileUtilsWinRT::getFileSize(const std::string &filepath) +{ + WIN32_FILE_ATTRIBUTE_DATA fad; + if (!GetFileAttributesEx(StringUtf8ToWideChar(filepath).c_str(), GetFileExInfoStandard, &fad)) + { + return 0; // error condition, could call GetLastError to find out more + } + LARGE_INTEGER size; + size.HighPart = fad.nFileSizeHigh; + size.LowPart = fad.nFileSizeLow; + return (long)size.QuadPart; +} + bool CCFileUtilsWinRT::isFileExistInternal(const std::string& strFilePath) const { bool ret = false; diff --git a/cocos/platform/winrt/CCFileUtilsWinRT.h b/cocos/platform/winrt/CCFileUtilsWinRT.h index 3d57b9d2f0..47538d4357 100644 --- a/cocos/platform/winrt/CCFileUtilsWinRT.h +++ b/cocos/platform/winrt/CCFileUtilsWinRT.h @@ -53,6 +53,7 @@ public: virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) const override; virtual std::string getStringFromFile(const std::string& filename) override; virtual std::string getSuitableFOpen(const std::string& filenameUtf8) const override; + virtual long getFileSize(const std::string &filepath); static std::string getAppPath(); private: