From f48a6840743641be4555edc42cb3c92287fff1b8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 19:23:18 +0000 Subject: [PATCH] fix stat being wrong --- src/common/fs/file.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/common/fs/file.cpp b/src/common/fs/file.cpp index 854090e7b2..96fb483dbf 100644 --- a/src/common/fs/file.cpp +++ b/src/common/fs/file.cpp @@ -20,6 +20,9 @@ #else #include #endif +#ifdef __OPENORBIS__ +#include +#endif #ifdef _MSC_VER #define fileno _fileno @@ -402,28 +405,27 @@ u64 IOFile::GetSize() const { file_size = Android::GetSize(file_path); } else { std::error_code ec; - file_size = fs::file_size(file_path, ec); - if (ec) { - LOG_ERROR(Common_Filesystem, - "Failed to retrieve the file size of path={}, ec_message={}", - PathToUTF8String(file_path), ec.message()); + LOG_ERROR(Common_Filesystem, "Failed to retrieve the file size of path={}, ec_message={}", PathToUTF8String(file_path), ec.message()); return 0; } } +#elif defined(__OPENORBIS__) + // TODO: implementation of fs::file_size() is buggy on PS4, why? + // probably toolchain issue... ugh + OrbisKernelStat st{}; + stat(file_path.c_str(), reinterpret_cast(std::addressof(st))); + auto const file_size = st.st_size; + LOG_DEBUG(Common_Filesystem, "size for {} = {}", file_path.c_str(), file_size); #else std::error_code ec; - const auto file_size = fs::file_size(file_path, ec); - if (ec) { - LOG_ERROR(Common_Filesystem, "Failed to retrieve the file size of path={}, ec_message={}", - PathToUTF8String(file_path), ec.message()); + LOG_ERROR(Common_Filesystem, "Failed to retrieve the file size of path={}, ec_message={}", PathToUTF8String(file_path), ec.message()); return 0; } #endif - return file_size; }