diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index 84b0965d44..809044353d 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -198,7 +198,7 @@ void SymbolMap::SaveSymbolMap(const Path &filename) const { #if defined(_WIN32) && defined(UNICODE) gzFile f = gzopen_w(filename.ToWString().c_str(), "w9"); #else - // TODO(scoped): We're screwed here + // TODO(scoped): Use gzdopen? If we care, otherwise just compress into a buffer. gzFile f = gzopen(filename.c_str(), "w9"); #endif diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 77061e83ad..4ad17643d4 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -181,8 +181,7 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) { return IdentifiedFileType::PSP_PBP_DIRECTORY; } return IdentifiedFileType::PSP_PBP; - } - else if (extension == ".pbp") { + } else if (extension == ".pbp") { ERROR_LOG(LOADER, "A PBP with the wrong magic number?"); return IdentifiedFileType::PSP_PBP; } else if (extension == ".bin") { diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index e20cbed323..75cc27e4c5 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -263,7 +263,7 @@ bool GameManager::InstallGame(Path url, Path fileName, bool deleteAfter) { return false; } - if (!File::Exists(Path(fileName))) { + if (!File::Exists(fileName)) { ERROR_LOG(HLE, "Game file '%s' doesn't exist", fileName.c_str()); return false; } @@ -272,7 +272,7 @@ bool GameManager::InstallGame(Path url, Path fileName, bool deleteAfter) { // Examine the URL to guess out what we're installing. if (extension == "cso" || extension == "iso") { // It's a raw ISO or CSO file. We just copy it to the destination. - std::string shortFilename = Path(url).GetFilename(); + std::string shortFilename = url.GetFilename(); return InstallRawISO(fileName, shortFilename, deleteAfter); } @@ -319,7 +319,7 @@ bool GameManager::InstallGame(Path url, Path fileName, bool deleteAfter) { zip_close(z); z = nullptr; if (deleteAfter) - File::Delete(Path(fileName)); + File::Delete(fileName); return false; } } @@ -473,7 +473,7 @@ bool GameManager::ExtractFile(struct zip *z, int file_index, const Path &outFile delete[] buffer; fclose(f); zip_fclose(zf); - File::Delete(Path(outFilename)); + File::Delete(outFilename); return false; } size_t written = fwrite(buffer, 1, readSize, f); @@ -482,7 +482,7 @@ bool GameManager::ExtractFile(struct zip *z, int file_index, const Path &outFile delete[] buffer; fclose(f); zip_fclose(zf); - File::Delete(Path(outFilename)); + File::Delete(outFilename); return false; } pos += readSize; @@ -531,16 +531,20 @@ bool GameManager::InstallMemstickGame(struct zip *z, const Path &zipfile, const continue; } std::string outFilename = dest + zippedName.substr(info.stripChars); - // TODO(scoped): Tricky logic - bool isDir = *outFilename.rbegin() == '/'; + + 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('/')); } Path outPath(outFilename); if (createdDirs.find(outPath) == createdDirs.end()) { - File::CreateFullPath(Path(outPath)); - createdDirs.insert(Path(outPath)); + File::CreateFullPath(outPath); + createdDirs.insert(outPath); } if (!isDir && fileAllowed(fn)) { struct zip_stat zstat; diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index 3b4cfaef33..169b00b0f1 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -148,14 +148,14 @@ static std::string RemotePathForRecent(const std::string &filename) { return ""; } -static std::string LocalFromRemotePath(const std::string &path) { +static Path LocalFromRemotePath(const std::string &path) { for (const std::string &filename : g_Config.recentIsos) { std::string basename = RemotePathForRecent(filename); if (basename == path) { - return filename; + return Path(filename); } } - return ""; + return Path(); } static void DiscHandler(const http::Request &request, const Path &filename) { @@ -229,10 +229,9 @@ static void HandleListing(const http::Request &request) { static void HandleFallback(const http::Request &request) { if (serverFlags & (int)WebServerFlags::DISCS) { - std::string filename = LocalFromRemotePath(request.resource()); + Path filename = LocalFromRemotePath(request.resource()); if (!filename.empty()) { - // TODO(scoped): Is this right? - DiscHandler(request, Path(filename)); + DiscHandler(request, filename); return; } } diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index d2ddd36381..592d23f182 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -98,8 +98,7 @@ bool GameInfo::Delete() { { const Path &ppstPath = filePath_; File::Delete(ppstPath); - // TODO(scoped): This doesn't work properly with Content URIs. - const Path screenshotPath = Path(ReplaceAll(filePath_.ToString(), ".ppst", ".jpg")); + const Path screenshotPath = filePath_.WithReplacedExtension(".ppst", ".jpg"); if (File::Exists(screenshotPath)) { File::Delete(screenshotPath); } @@ -372,7 +371,7 @@ public: if (pbp.IsELF()) { goto handleELF; } - ERROR_LOG(LOADER, "invalid pbp '%s'\n", pbpLoader->GetPath().c_str()); + ERROR_LOG(LOADER, "invalid pbp '%s'\n", pbpLoader->GetPath().ToVisualString().c_str()); info_->pending = false; info_->working = false; return; diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index c88c8a34f2..901a5fb09a 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -579,9 +579,9 @@ void NewLanguageScreen::OnCompleted(DialogResult result) { void LogoScreen::Next() { if (!switched_) { switched_ = true; - Path gamePath = Path(boot_filename); + Path gamePath = boot_filename; if (gotoGameSettings_) { - if (boot_filename.size()) { + if (!gamePath.empty()) { screenManager()->switchScreen(new EmuScreen(gamePath)); } else { screenManager()->switchScreen(new MainScreen()); diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index b47ce5b45e..fe426a4a61 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -112,8 +112,7 @@ public: content->Add(new TextView(ReplaceAll(savedata_detail, "\r", ""), ALIGN_LEFT | FLAG_WRAP_TEXT, true, new LinearLayoutParams(Margins(10, 0))))->SetTextColor(textStyle.fgColor); content->Add(new Spacer(3.0)); } else { - // TODO(scoped): This can't work - Path image_path = Path(ReplaceAll(savePath_.ToString(), ".ppst", ".jpg")); + Path image_path = savePath_.WithReplacedExtension(".ppst", ".jpg"); if (File::Exists(image_path)) { toprow->Add(new AsyncImageFileView(Path(image_path), IS_KEEP_ASPECT, new LinearLayoutParams(480, 272, Margins(10, 0)))); } else {