diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index 12d93c8639..44a1675394 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -234,6 +234,10 @@ ZipFileContents DetectZipFileContents(struct zip *z, ZipFileInfo *info) { std::string zippedName = fn; std::transform(zippedName.begin(), zippedName.end(), zippedName.begin(), [](unsigned char c) { return asciitolower(c); }); // Not using std::tolower to avoid Turkish I->ı conversion. + // Ignore macos metadata stuff + if (startsWith(zippedName, "__macosx/")) { + continue; + } if (zippedName.find("eboot.pbp") != std::string::npos) { int slashCount = 0; int slashLocation = -1; @@ -251,7 +255,12 @@ ZipFileContents DetectZipFileContents(struct zip *z, ZipFileInfo *info) { if (slashCount <= 1) { // We only do this if the ISO file is in the root or one level down. isZippedISO = true; - isoFileIndex = i; + INFO_LOG(Log::HLE, "ISO found in zip: %s", zippedName.c_str()); + if (isoFileIndex != -1) { + INFO_LOG(Log::HLE, "More than one ISO file found in zip. Ignoring additional ones."); + } else { + isoFileIndex = i; + } } } else if (zippedName.find("textures.ini") != std::string::npos) { int slashLocation = (int)zippedName.find_last_of('/'); @@ -493,11 +502,6 @@ bool GameManager::ExtractFile(struct zip *z, int file_index, const Path &outFile zip_stat_index(z, file_index, 0, &zstat); size_t size = zstat.size; - // Don't spam the log. - if (file_index < 10) { - INFO_LOG(Log::HLE, "Writing %d bytes to '%s'", (int)size, outFilename.c_str()); - } - zip_file *zf = zip_fopen_index(z, file_index, 0); if (!zf) { ERROR_LOG(Log::HLE, "Failed to open file by index (%d) (%s)", file_index, outFilename.c_str()); @@ -506,6 +510,10 @@ bool GameManager::ExtractFile(struct zip *z, int file_index, const Path &outFile FILE *f = File::OpenCFile(outFilename, "wb"); if (f) { + // Don't spam the log. + if (file_index < 10) { + INFO_LOG(Log::HLE, "Writing %d bytes to '%s'", (int)size, outFilename.c_str()); + } size_t pos = 0; const size_t blockSize = 1024 * 128; u8 *buffer = new u8[blockSize]; @@ -729,7 +737,16 @@ bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, const Path & allBytes += zstat.size; } - Path outputISOFilename = Path(g_Config.currentDirectory) / fn.substr(nameOffset); + std::string name = fn.substr(nameOffset); + + INFO_LOG(Log::IO, "Name in zip: %s size: %d", name.c_str(), (int)zstat.size); + + if (startsWith(name, "._")) { + // Not sure why Apple seems to add this when zipping file? + name = name.substr(2); + } + + Path outputISOFilename = Path(g_Config.currentDirectory) / name; size_t bytesCopied = 0; bool success = false; auto di = GetI18NCategory(I18NCat::DIALOG); diff --git a/UI/InstallZipScreen.cpp b/UI/InstallZipScreen.cpp index a85f898a61..9e1c20cfd6 100644 --- a/UI/InstallZipScreen.cpp +++ b/UI/InstallZipScreen.cpp @@ -50,7 +50,7 @@ void InstallZipScreen::CreateViews() { std::string shortFilename = zipPath_.GetFilename(); // TODO: Do in the background? - ZipFileInfo zipInfo; + ZipFileInfo zipInfo{}; ZipFileContents contents = DetectZipFileContents(zipPath_, &zipInfo); if (contents == ZipFileContents::ISO_FILE || contents == ZipFileContents::PSP_GAME_DIR) { diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 4353e11c5e..d9967550e0 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -695,8 +695,12 @@ bool GameBrowser::HasSpecialFiles(std::vector &filenames) { void GameBrowser::Update() { LinearLayout::Update(); - if (listingPending_ && path_.IsListingReady()) { + if (refreshPending_) { + path_.Refresh(); + } + if ((listingPending_ && path_.IsListingReady()) || refreshPending_) { Refresh(); + refreshPending_ = false; } if (searchPending_) { ApplySearchFilter(); @@ -1615,6 +1619,12 @@ void MainScreen::dialogFinished(const Screen *dialog, DialogResult result) { g_BackgroundAudio.SetGame(Path()); } } + if (tag == "InstallZip") { + INFO_LOG(Log::System, "InstallZip finished, refreshing"); + if (gameBrowsers_.size() >= 2) { + gameBrowsers_[1]->RequestRefresh(); + } + } } void UmdReplaceScreen::CreateViews() { diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 26cbf2d463..026f967410 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -55,6 +55,9 @@ public: void ApplySearchFilter(const std::string &filter); void Draw(UIContext &dc) override; void Update() override; + void RequestRefresh() { + refreshPending_ = true; + } void SetHomePath(const Path &path) { homePath_ = path; @@ -106,6 +109,7 @@ private: Path focusGamePath_; bool listingPending_ = false; bool searchPending_ = false; + bool refreshPending_ = false; float lastScale_ = 1.0f; bool lastLayoutWasGrid_ = true; ScreenManager *screenManager_;