From 16d757651c48049ac7dbc8f843e4dcc4d7a86601 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Wed, 3 Aug 2022 20:08:06 +0800 Subject: [PATCH] Fix Android game size --- UI/GameScreen.cpp | 19 ++++--------------- UI/GameScreen.h | 5 +++-- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 932f8c9945..bf9d286d16 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -46,10 +46,6 @@ #include "Core/Reporting.h" #include "Common/Crypto/md5.h" #include -#include -#ifdef _WIN32 -#define stat64 _stat64 -#endif GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { @@ -323,6 +319,7 @@ void GameScreen::render() { if (tvGameSize_) { snprintf(temp, sizeof(temp), "%s: %1.1f %s", ga->T("Game"), (float)(info->gameSize) / 1024.f / 1024.f, ga->T("MB")); tvGameSize_->SetText(temp); + sfilesize = info->gameSize; } /* if (tvSaveDataSize_) { @@ -461,28 +458,20 @@ std::string MD5_262144_File(const Path filename) { return res; } -long long sFileSize(const Path filename) { - struct stat64 st; - - if (stat64(filename.c_str(), &st) == 0) - return st.st_size; - - return -1; -} UI::EventReturn GameScreen::OnDoMD5(UI::EventParams& e) { MD5string = ""; MD5string = MD5FullFile(gamePath_) + "#"; - long long tempfilesize = sFileSize(gamePath_); - if (tempfilesize <= 262144) { + + if (sfilesize <= 262144) { MD5string = MD5string + MD5FullFile(gamePath_); } else { MD5string = MD5string + MD5_262144_File(gamePath_); } - MD5string = MD5string + "#" + std::to_string(tempfilesize) + "#"+ gamePath_.GetFilename(); + MD5string = MD5string + "#" + std::to_string(sfilesize) + "#"+ gamePath_.GetFilename(); btnCalcMD5_->SetEnabled(false); tvMD5_->SetText(MD5string); return UI::EVENT_DONE; diff --git a/UI/GameScreen.h b/UI/GameScreen.h index d6069e9373..609f8c5765 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -89,6 +89,7 @@ private: std::vector otherChoices_; std::vector saveDirs; - std::string CRC32string; - std::string MD5string; + std::string CRC32string = ""; + std::string MD5string = ""; + u64 sfilesize = 0; };