diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index ee273f6e36..0f340dda06 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -1,4 +1,5 @@ #include "ppsspp_config.h" +#include #include "Common/File/Path.h" #include "Common/StringUtils.h" @@ -117,6 +118,16 @@ std::string Path::GetFileExtension() const { std::string Path::GetDirectory() const { size_t pos = path_.rfind('/'); + if (type_ == PathType::HTTP) { + // Things are a bit different for HTTP, because we probably ended with /. + if (pos + 1 == path_.size()) { + pos = path_.rfind('/', pos - 1); + if (pos != path_.npos && pos > 8) { + return path_.substr(0, pos + 1); + } + } + } + if (pos != std::string::npos) { if (pos == 0) { return "/"; // We're at the root. @@ -176,6 +187,13 @@ bool Path::CanNavigateUp() const { if (path_ == "/" || path_ == "") { return false; } + if (type_ == PathType::HTTP) { + size_t rootSlash = path_.find_first_of('/', strlen("https://")); + if (rootSlash == path_.npos || path_.size() < rootSlash + 1) { + // This means, "http://server" or "http://server/". Can't go up. + return false; + } + } return true; } diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 6608481636..2ef8c092ec 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -149,7 +149,7 @@ void PathBrowser::HandlePath() { return; } - if (path_.Type() == PathType::HTTP) { + if (path_.Type() != PathType::HTTP) { if (pendingActive_) ResetPending(); ready_ = true; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 61f3732b9c..5640fd622b 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -541,14 +541,18 @@ UI::EventReturn GameBrowser::StorageClick(UI::EventParams &e) { } UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) { -#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) - SetPath(g_Config.memStickDirectory); -#else - SetPath(Path(getenv("HOME"))); -#endif + SetPath(HomePath()); return UI::EVENT_DONE; } +Path GameBrowser::HomePath() { +#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP) + return g_Config.memStickDirectory; +#else + return Path(getenv("HOME")); +#endif +} + UI::EventReturn GameBrowser::PinToggleClick(UI::EventParams &e) { auto &pinnedPaths = g_Config.vPinnedPaths; const std::string path = File::ResolvePath(path_.GetPath().ToString()); diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 51d500b798..9a19321755 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -57,6 +57,7 @@ public: protected: virtual bool DisplayTopBar(); virtual bool HasSpecialFiles(std::vector &filenames); + virtual Path HomePath(); void Refresh(); diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index eb14a3e023..b5d80bf76d 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -251,7 +251,7 @@ static bool LoadGameList(const Path &url, std::vector &games) { return false; } for (auto &file : files) { - if (RemoteISOFileSupported(file.name)) { + if (file.isDirectory || RemoteISOFileSupported(file.name)) { games.push_back(file.fullName); } } @@ -498,28 +498,19 @@ void RemoteISOConnectScreen::ExecuteLoad() { class RemoteGameBrowser : public GameBrowser { public: - RemoteGameBrowser(const Path &url, const std::vector &games, BrowseFlags browseFlags, bool *gridStyle_, ScreenManager* screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr) + RemoteGameBrowser(const Path &url, BrowseFlags browseFlags, bool *gridStyle_, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr) : GameBrowser(url, browseFlags, gridStyle_, screenManager, lastText, lastLink, layoutParams) { - games_ = games; - Refresh(); + initialPath_ = url; } protected: - bool DisplayTopBar() override { - return false; + Path HomePath() override { + return initialPath_; } - bool HasSpecialFiles(std::vector &filenames) override; - - std::string url_; - std::vector games_; + Path initialPath_; }; -bool RemoteGameBrowser::HasSpecialFiles(std::vector &filenames) { - filenames = games_; - return true; -} - RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::vector &games) : url_(url), games_(games) { } @@ -541,8 +532,8 @@ void RemoteISOBrowseScreen::CreateViews() { ScrollView *scrollRecentGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); scrollRecentGames->SetTag("RemoteGamesTab"); - RemoteGameBrowser *tabRemoteGames = new RemoteGameBrowser( - Path(url_), games_, BrowseFlags::PIN, &g_Config.bGridView1, screenManager(), "", "", + GameBrowser *tabRemoteGames = new RemoteGameBrowser( + Path(url_), BrowseFlags::PIN | BrowseFlags::NAVIGATE, &g_Config.bGridView1, screenManager(), "", "", new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); scrollRecentGames->Add(tabRemoteGames); gameBrowsers_.push_back(tabRemoteGames);