From 0e47a7986dc5cea404f0e7bc886848c6addafee4 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Tue, 9 Dec 2008 22:54:57 +0000 Subject: [PATCH] Fix filesize computation broken by XtraKrazzy in R1405 git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1468 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 22bcc152f2..1714348e9e 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -319,17 +319,26 @@ std::string GetUserDirectory() u64 GetSize(const char *filename) { - if(!Exists(filename)) + if (!Exists(filename)) return 0; - +#ifdef _WIN32 + // stat doesn't support 64-bit file sizes on Win32. + FILE *pFile = fopen(filename, "rb"); + if (pFile) + { + fseek(pFile, 0, SEEK_END); + u64 pos = ftell(pFile); + fclose(pFile); + return pos; + } +#else struct stat buf; if (stat(filename, &buf) == 0) { return buf.st_size; } int err = errno; - - PanicAlert("Error accessing %s: %s", filename, strerror(err)); - + PanicAlert("Error accessing %s: %s", filename, strerror(err)); +#endif return 0; }