diff --git a/Core/Util/PathUtil.cpp b/Core/Util/PathUtil.cpp index c8219cbded..ad7f847235 100644 --- a/Core/Util/PathUtil.cpp +++ b/Core/Util/PathUtil.cpp @@ -185,18 +185,20 @@ Path GetFailedBackendsDir() { return failedBackendsDir; } -std::string GetFriendlyPath(Path path, Path aliasMatch, std::string_view aliasDisplay) { +std::string GetFriendlyPath(Path path, const Path &rootMatch, std::string_view rootDisplay) { + const Path &root = rootMatch.empty() ? g_Config.memStickDirectory : rootMatch; + // Show relative to memstick root if there. - if (path.StartsWith(aliasMatch)) { + if (path.StartsWith(rootMatch)) { std::string p; - if (aliasMatch.ComputePathTo(path, p)) { - return join(aliasDisplay, p); + if (rootMatch.ComputePathTo(path, p)) { + return join(rootDisplay, p); } std::string str = path.ToString(); - if (aliasMatch.size() < str.length()) { - return join(aliasDisplay, str.substr(aliasMatch.size())); + if (rootMatch.size() < str.length()) { + return join(rootDisplay, str.substr(rootMatch.size())); } else { - return std::string(aliasDisplay); + return std::string(rootDisplay); } } @@ -204,7 +206,7 @@ std::string GetFriendlyPath(Path path, Path aliasMatch, std::string_view aliasDi #if !PPSSPP_PLATFORM(ANDROID) && (PPSSPP_PLATFORM(LINUX) || PPSSPP_PLATFORM(MAC)) char *home = getenv("HOME"); if (home != nullptr && !strncmp(str.c_str(), home, strlen(home))) { - return std::string("~") + str.substr(strlen(home)); + return "~" + str.substr(strlen(home)); } #endif return path.ToVisualString(); diff --git a/Core/Util/PathUtil.h b/Core/Util/PathUtil.h index 5c09ce053c..55be307e31 100644 --- a/Core/Util/PathUtil.h +++ b/Core/Util/PathUtil.h @@ -35,4 +35,4 @@ bool CreateSysDirectories(); Path GetGameConfigFilePath(const Path &searchPath, std::string_view gameId, bool *exists); bool TryUpdateSavedPath(Path *path); Path GetFailedBackendsDir(); -std::string GetFriendlyPath(Path path, Path aliasMatch, std::string_view aliasDisplay); +std::string GetFriendlyPath(Path path, const Path &rootMatch = Path(), std::string_view rootDisplay = "ms:/"); diff --git a/UI/InstallZipScreen.cpp b/UI/InstallZipScreen.cpp index a614234dba..e9fc3b0682 100644 --- a/UI/InstallZipScreen.cpp +++ b/UI/InstallZipScreen.cpp @@ -19,15 +19,17 @@ #include "Common/UI/View.h" #include "Common/UI/ViewGroup.h" #include "Common/UI/Notice.h" - #include "Common/StringUtils.h" #include "Common/File/FileUtil.h" #include "Common/Data/Text/I18n.h" #include "Common/Data/Text/Parsers.h" + #include "Core/Config.h" #include "Core/System.h" #include "Core/Util/GameManager.h" +#include "Core/Util/PathUtil.h" #include "Core/Loaders.h" + #include "UI/InstallZipScreen.h" #include "UI/MainScreen.h" #include "UI/OnScreenDisplay.h" @@ -126,7 +128,7 @@ void InstallZipScreen::CreateContentViews(UI::ViewGroup *parent) { destFolders_.clear(); std::vector destOptions; - + bool overwrite = false; switch (zipFileInfo_.contents) { case ZipFileContents::ISO_FILE: case ZipFileContents::PSP_GAME_DIR: @@ -175,20 +177,16 @@ void InstallZipScreen::CreateContentViews(UI::ViewGroup *parent) { { std::string_view question = iz->T("Import savestates from ZIP file"); leftColumn->Add(new TextView(question))->SetBig(true); - leftColumn->Add(new TextView(zipPath_.ToVisualString())); + leftColumn->Add(new TextView(GetFriendlyPath(zipPath_))); leftColumn->Add(new TextView(zipFileInfo_.gameTitle)); Path savestateDir = GetSysDirectory(DIRECTORY_SAVESTATE); ZipContainer zipFile = ZipOpenPath(zipPath_); - bool overwrite = !CanExtractWithoutOverwrite(zipFile, savestateDir, 50); + overwrite = !CanExtractWithoutOverwrite(zipFile, savestateDir, 50); ZipClose(zipFile); destFolders_.push_back(savestateDir); - if (overwrite) { - leftColumn->Add(new NoticeView(NoticeLevel::WARN, di->T("Confirm Overwrite"), "")); - } - // TODO: Use the GameInfoCache to display data about the game if available. doneView_ = leftColumn->Add(new TextView("")); showDeleteCheckbox = true; @@ -202,15 +200,10 @@ void InstallZipScreen::CreateContentViews(UI::ViewGroup *parent) { Path savedataDir = GetSysDirectory(DIRECTORY_SAVEDATA); ZipContainer zipFile = ZipOpenPath(zipPath_); - bool overwrite = !CanExtractWithoutOverwrite(zipFile, savedataDir, 50); + overwrite = !CanExtractWithoutOverwrite(zipFile, savedataDir, 50); ZipClose(zipFile); destFolders_.push_back(savedataDir); - - if (overwrite) { - leftColumn->Add(new NoticeView(NoticeLevel::WARN, di->T("Confirm Overwrite"), "")); - } - int columnWidth = 300; LinearLayout *compareColumns = leftColumn->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); @@ -262,6 +255,10 @@ void InstallZipScreen::CreateContentViews(UI::ViewGroup *parent) { leftColumn->Add(new TextView(iz->T("Install into folder"))); leftColumn->Add(new TextView(destFolders_[0].ToVisualString()))->SetAlign(FLAG_WRAP_TEXT); } + + if (overwrite) { + leftColumn->Add(new NoticeView(NoticeLevel::WARN, di->T("Confirm Overwrite"), "")); + } } void InstallZipScreen::BeforeCreateViews() {