From 66b7e21676524f7ca500e8dcf824c20bbc741fb3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 11 May 2021 22:43:15 -0700 Subject: [PATCH] GameManager: Base isDir off of zipped file name. --- Core/Util/GameManager.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index 75cc27e4c5..c606f79d73 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -532,13 +532,11 @@ bool GameManager::InstallMemstickGame(struct zip *z, const Path &zipfile, const } std::string outFilename = dest + zippedName.substr(info.stripChars); - zip_uint32_t attrs = 0; - if (0 != zip_file_get_external_attributes(z, i, 0, nullptr, &attrs)) { - continue; - } - bool isDir = attrs & - if (!isDir && outFilename.find("/") != std::string::npos) { - outFilename = outFilename.substr(0, outFilename.rfind('/')); + bool isDir = zippedName.empty() || zippedName.back() == '/'; + if (!isDir && zippedName.find("/") != std::string::npos) { + outFilename = dest + zippedName.substr(0, zippedName.rfind('/')); + } else if (!isDir) { + outFilename = dest; } Path outPath(outFilename); @@ -561,9 +559,10 @@ bool GameManager::InstallMemstickGame(struct zip *z, const Path &zipfile, const // Note that we do NOT write files that are not in a directory, to avoid random // README files etc. (unless allowRoot is true.) if (fileAllowed(fn) && strlen(fn) > (size_t)info.stripChars) { + std::string zippedName = fn; fn += info.stripChars; std::string outFilename = dest + fn; - bool isDir = *outFilename.rbegin() == '/'; + bool isDir = zippedName.empty() || zippedName.back() == '/'; if (isDir) continue;