diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index c3f0c26675..a86f9f246f 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -15,15 +15,12 @@ #include "Common/Log.h" #include "Common/Thread/ThreadUtil.h" -#include "Core/Config.h" -#include "Core/System.h" - #if PPSSPP_PLATFORM(ANDROID) #include "android/jni/app-android.h" #include "android/jni/AndroidContentURI.h" #endif -bool LoadRemoteFileList(const Path &url, bool *cancel, std::vector &files) { +bool LoadRemoteFileList(const Path &url, const std::string &userAgent, bool *cancel, std::vector &files) { _dbg_assert_(url.Type() == PathType::HTTP); http::Client http; @@ -31,7 +28,7 @@ bool LoadRemoteFileList(const Path &url, bool *cancel, std::vector responseHeaders; - http.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION)); + http.SetUserAgent(userAgent); Url baseURL(url.ToString()); if (!baseURL.Valid()) { @@ -159,7 +156,7 @@ void PathBrowser::HandlePath() { if (lastPath.Type() == PathType::HTTP) { guard.unlock(); results.clear(); - success = LoadRemoteFileList(lastPath, &pendingCancel_, results); + success = LoadRemoteFileList(lastPath, userAgent_, &pendingCancel_, results); guard.lock(); } else if (lastPath.empty()) { results.clear(); @@ -196,10 +193,8 @@ bool PathBrowser::IsListingReady() { std::string PathBrowser::GetFriendlyPath() const { std::string str = GetPath().ToVisualString(); // Show relative to memstick root if there. - std::string root = GetSysDirectory(DIRECTORY_MEMSTICK_ROOT).ToVisualString(); - - if (startsWith(str, root)) { - return std::string("ms:") + str.substr(root.size()); + if (startsWith(str, aliasMatch_)) { + return aliasDisplay_ + str.substr(aliasMatch_.size()); } #if PPSSPP_PLATFORM(LINUX) || PPSSPP_PLATFORM(MAC) diff --git a/Common/File/PathBrowser.h b/Common/File/PathBrowser.h index 9f10cde560..aa7c7c068f 100644 --- a/Common/File/PathBrowser.h +++ b/Common/File/PathBrowser.h @@ -35,6 +35,14 @@ public: } std::string GetFriendlyPath() const; + void SetUserAgent(const std::string &s) { + userAgent_ = s; + } + void SetRootAlias(const std::string &alias, const std::string &longValue) { + aliasDisplay_ = alias; + aliasMatch_ = longValue; + } + bool empty() const { return path_.empty(); } @@ -45,6 +53,9 @@ private: Path path_; Path pendingPath_; + std::string userAgent_; + std::string aliasDisplay_; + std::string aliasMatch_; std::vector pendingFiles_; std::condition_variable pendingCond_; std::mutex pendingLock_; diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index aa471cfdfa..bc7120abc2 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -12,7 +12,6 @@ #include "Common/GPU/Vulkan/VulkanContext.h" #include "Common/GPU/Vulkan/VulkanDebug.h" #include "Common/StringUtils.h" -#include "Core/Config.h" #ifdef USE_CRT_DBG #undef new diff --git a/Common/Net/HTTPClient.h b/Common/Net/HTTPClient.h index e96102ce05..cafe4b08c5 100644 --- a/Common/Net/HTTPClient.h +++ b/Common/Net/HTTPClient.h @@ -87,7 +87,7 @@ public: dataTimeout_ = t; } - void SetUserAgent(const std::string &&value) { + void SetUserAgent(const std::string &value) { userAgent_ = value; } diff --git a/UI/ComboKeyMappingScreen.cpp b/UI/ComboKeyMappingScreen.cpp index 4af85552c1..edfea23bc8 100644 --- a/UI/ComboKeyMappingScreen.cpp +++ b/UI/ComboKeyMappingScreen.cpp @@ -24,7 +24,6 @@ #include "Common/Data/Text/I18n.h" #include "Common/Data/Color/RGBAUtil.h" -#include "Common/File/PathBrowser.h" #include "Common/Math/curves.h" #include "Common/TimeUtil.h" #include "Common/StringUtils.h" diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 5a03804908..cc273ebbd1 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -505,6 +505,8 @@ void DirButton::Draw(UIContext &dc) { GameBrowser::GameBrowser(const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams) : LinearLayout(UI::ORIENT_VERTICAL, layoutParams), path_(path), gridStyle_(gridStyle), browseFlags_(browseFlags), lastText_(lastText), lastLink_(lastLink), screenManager_(screenManager) { using namespace UI; + path_.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION)); + path_.SetRootAlias("ms:", GetSysDirectory(DIRECTORY_MEMSTICK_ROOT).ToVisualString()); Refresh(); } diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 93e2ae7681..26b5c7c36d 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -40,6 +40,7 @@ #include "Common/System/System.h" #include "Common/TimeUtil.h" #include "Core/Config.h" +#include "Core/System.h" #include "Core/WebServer.h" #include "UI/RemoteISOScreen.h" @@ -247,6 +248,8 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort static bool LoadGameList(const Path &url, std::vector &games) { PathBrowser browser(url); std::vector files; + browser.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION)); + browser.SetRootAlias("ms:", GetSysDirectory(DIRECTORY_MEMSTICK_ROOT).ToVisualString()); browser.GetListing(files, "iso:cso:pbp:elf:prx:ppdmp:", &scanCancelled); if (scanCancelled) { return false;