diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 061313fad2..b9263a4328 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -562,10 +562,10 @@ bool Move(const Path &srcFilename, const Path &destFilename) { // Returns the size of file (64bit) // TODO: Add a way to return an error. -uint64_t GetFileSize(const std::string &filename) { +uint64_t GetFileSize(const Path &filename) { #if defined(_WIN32) && defined(UNICODE) WIN32_FILE_ATTRIBUTE_DATA attr; - if (!GetFileAttributesEx(ConvertUTF8ToWString(filename).c_str(), GetFileExInfoStandard, &attr)) + if (!GetFileAttributesEx(filename.ToWString().c_str(), GetFileExInfoStandard, &attr)) return 0; if (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) return 0; @@ -579,14 +579,14 @@ uint64_t GetFileSize(const std::string &filename) { int result = stat64(filename.c_str(), &file_info); #endif if (result != 0) { - WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.c_str()); + WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.ToVisualString().c_str()); return 0; } if (S_ISDIR(file_info.st_mode)) { - WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.c_str()); + WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.ToVisualString().c_str()); return 0; } - DEBUG_LOG(COMMON, "GetSize: %s: %lld", filename.c_str(), (long long)file_info.st_size); + DEBUG_LOG(COMMON, "GetSize: %s: %lld", filename.ToVisualString().c_str(), (long long)file_info.st_size); return file_info.st_size; #endif } diff --git a/Common/File/FileUtil.h b/Common/File/FileUtil.h index 6d5ae1d42d..8f06ed79e3 100644 --- a/Common/File/FileUtil.h +++ b/Common/File/FileUtil.h @@ -57,7 +57,7 @@ bool IsDirectory(const Path &filename); bool GetModifTime(const Path &filename, tm &return_time); // Returns the size of filename (64bit) -uint64_t GetFileSize(const std::string &filename); +uint64_t GetFileSize(const Path &filename); // Overloaded GetSize, accepts FILE* uint64_t GetFileSize(FILE *f); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 02032b481f..90bd14b1e7 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -142,7 +142,7 @@ void VirtualDiscFileSystem::LoadFileListIndex() { ERROR_LOG(FILESYS, "Unable to open virtual file: %s", entry.fileName.c_str()); } } else { - entry.totalSize = File::GetFileSize(GetLocalPath(entry.fileName).ToString()); + entry.totalSize = File::GetFileSize(GetLocalPath(entry.fileName)); } // Try to keep currentBlockIndex sane, in case there are other files. @@ -291,7 +291,7 @@ int VirtualDiscFileSystem::getFileListIndex(std::string &fileName) FileListEntry entry = {""}; entry.fileName = normalized; - entry.totalSize = File::GetFileSize(fullName.ToString()); + entry.totalSize = File::GetFileSize(fullName); entry.firstBlock = currentBlockIndex; currentBlockIndex += (entry.totalSize+2047)/2048; diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index 169b00b0f1..b3b1b9b333 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -159,7 +159,7 @@ static Path LocalFromRemotePath(const std::string &path) { } static void DiscHandler(const http::Request &request, const Path &filename) { - s64 sz = File::GetFileSize(filename.ToString()); + s64 sz = File::GetFileSize(filename); std::string range; if (request.Method() == http::RequestHeader::HEAD) {