From a40b1dec5f20cd982624d8b6aeeb46024cce2405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 9 May 2021 15:25:12 +0200 Subject: [PATCH] Use Path for fullName in dirlisting. Bugfixes. Buildfixes UWP: Buildfix. headless: Buildfix. Common: Buildfix. iOS: Buildfixes. libretro: Buildfix. Qt: Buildfix. --- Common/CPUDetect.cpp | 4 +-- Common/File/DirListing.cpp | 12 ++------ Common/File/DirListing.h | 2 +- Common/File/Path.cpp | 2 +- Common/File/PathBrowser.cpp | 6 ++-- Common/File/VFS/AssetReader.cpp | 17 ++++------- Common/MemArenaPosix.cpp | 2 +- Core/FileLoaders/DiskCachingFileLoader.cpp | 2 +- GPU/Common/PostShader.cpp | 21 ++++++------- GPU/Common/PostShader.h | 10 +++---- GPU/Common/PresentationCommon.cpp | 6 ++-- GPU/Vulkan/TextureCacheVulkan.cpp | 2 +- Qt/QtHost.cpp | 12 ++++---- Qt/QtHost.h | 6 ++-- Qt/mainwindow.cpp | 16 +++++----- UI/MainScreen.cpp | 34 ++++++++++++---------- UI/MainScreen.h | 5 ++-- UI/NativeApp.cpp | 8 ++--- UI/RemoteISOScreen.cpp | 12 ++++---- UI/RemoteISOScreen.h | 6 ++-- UI/SavedataScreen.cpp | 4 +-- UWP/PPSSPP_UWPMain.cpp | 8 ++--- UWP/UWPHost.cpp | 26 ++++++----------- android/jni/TestRunner.cpp | 4 +-- headless/Headless.cpp | 2 +- libretro/libretro.cpp | 6 ++-- 26 files changed, 108 insertions(+), 127 deletions(-) diff --git a/Common/CPUDetect.cpp b/Common/CPUDetect.cpp index aaa7c3e94a..01a4d06cf4 100644 --- a/Common/CPUDetect.cpp +++ b/Common/CPUDetect.cpp @@ -120,7 +120,7 @@ static std::vector ParseCPUList(const std::string &filename) { std::string data; std::vector results; - if (File::ReadFileToString(true, filename.c_str(), data)) { + if (File::ReadFileToString(true, Path(filename), data)) { std::vector ranges; SplitString(data, ',', ranges); for (auto range : ranges) { @@ -372,7 +372,7 @@ void CPUInfo::Detect() { // This seems to be the count per core. Hopefully all cores are the same, but we counted each above. logical_cpu_count /= std::max(num_cores, 1); #elif PPSSPP_PLATFORM(LINUX) - if (File::Exists("/sys/devices/system/cpu/present")) { + if (File::Exists(Path("/sys/devices/system/cpu/present"))) { // This may not count unplugged cores, but at least it's a best guess. // Also, this assumes the CPU cores are heterogeneous (e.g. all cores could be active simultaneously.) num_cores = 0; diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index b9b35b1b52..ea665b4276 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -45,7 +45,7 @@ bool GetFileInfo(const Path &path, FileInfo * fileInfo) { } // TODO: Expand relative paths? - fileInfo->fullName = path.ToString(); + fileInfo->fullName = path; #ifdef _WIN32 auto FiletimeToStatTime = [](FILETIME ft) { @@ -191,15 +191,7 @@ size_t GetFilesInDir(const Path &directory, std::vector * files, const FileInfo info; info.name = virtualName; - // It's OK not to use Path /-concat here. - std::string dir = directory.ToString(); - - // Only append a slash if there isn't one on the end. - size_t lastSlash = dir.find_last_of("/"); - if (lastSlash != (dir.length() - 1)) - dir.append("/"); - - info.fullName = dir + virtualName; + info.fullName = directory / virtualName; info.isDirectory = IsDirectory(Path(info.fullName)); info.exists = true; info.size = 0; diff --git a/Common/File/DirListing.h b/Common/File/DirListing.h index 64d06b5b32..f175796a95 100644 --- a/Common/File/DirListing.h +++ b/Common/File/DirListing.h @@ -13,7 +13,7 @@ namespace File { struct FileInfo { std::string name; - std::string fullName; // TODO: Make into Path + Path fullName; bool exists = false; bool isDirectory = false; bool isWritable = false; diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index 83798b099e..b653a1e87c 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -55,7 +55,7 @@ Path Path::WithExtraExtension(const std::string &ext) const { Path Path::WithReplacedExtension(const std::string &oldExtension, const std::string &newExtension) const { if (endsWithNoCase(path_, "." + oldExtension)) { - std::string newPath = path_.substr(path_.size() - oldExtension.size() - 1); + std::string newPath = path_.substr(0, path_.size() - oldExtension.size() - 1); return Path(newPath + "." + newExtension); } else { return Path(*this); diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index b46f2c5257..5c066d2d56 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -83,7 +83,7 @@ bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vector ApplyFilter(std::vector files, const auto pred = [&](const File::FileInfo &info) { if (info.isDirectory || !filter) return false; - std::string ext = File::GetFileExtension(info.fullName); + std::string ext = info.fullName.GetFileExtension(); return filters.find(ext) == filters.end(); }; files.erase(std::remove_if(files.begin(), files.end(), pred), files.end()); @@ -255,7 +255,7 @@ bool PathBrowser::GetListing(std::vector &fileInfo, const char * if (*drive == "A:/" || *drive == "B:/") continue; File::FileInfo fake; - fake.fullName = *drive; + fake.fullName = Path(*drive); fake.name = *drive; fake.isDirectory = true; fake.exists = true; diff --git a/Common/File/VFS/AssetReader.cpp b/Common/File/VFS/AssetReader.cpp index eed0ce2ce9..b8729d39bf 100644 --- a/Common/File/VFS/AssetReader.cpp +++ b/Common/File/VFS/AssetReader.cpp @@ -113,13 +113,9 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vectorfullName = path; + info->fullName = Path(path); info->exists = true; // TODO info->isWritable = false; info->isDirectory = false; // TODO diff --git a/Common/MemArenaPosix.cpp b/Common/MemArenaPosix.cpp index 7df84ab35c..3701f5c377 100644 --- a/Common/MemArenaPosix.cpp +++ b/Common/MemArenaPosix.cpp @@ -56,7 +56,7 @@ void MemArena::GrabLowMemSpace(size_t size) { // Some platforms (like Raspberry Pi) end up flushing to disk. // To avoid this, we try to use /dev/shm (tmpfs) if it exists. fd = -1; - if (File::Exists(tmpfs_location)) { + if (File::Exists(Path(tmpfs_location))) { fd = open(tmpfs_ram_temp_file.c_str(), O_RDWR | O_CREAT, mode); if (fd >= 0) { // Great, this definitely shouldn't flush to disk. diff --git a/Core/FileLoaders/DiskCachingFileLoader.cpp b/Core/FileLoaders/DiskCachingFileLoader.cpp index 908eb14024..eedb6471d3 100644 --- a/Core/FileLoaders/DiskCachingFileLoader.cpp +++ b/Core/FileLoaders/DiskCachingFileLoader.cpp @@ -827,7 +827,7 @@ void DiskCachingFileLoaderCache::GarbageCollectCacheFiles(u64 goalBytes) { } #ifdef _WIN32 - const std::wstring w32path = ConvertUTF8ToWString(file.fullName); + const std::wstring w32path = file.fullName.ToWString(); bool success = DeleteFileW(w32path.c_str()) != 0; #else bool success = unlink(file.fullName.c_str()) == 0; diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index 2ee01b8e3d..d6d23cb9f5 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -88,18 +88,19 @@ void LoadPostShaderInfo(const std::vector &directories) { for (size_t f = 0; f < fileInfo.size(); f++) { IniFile ini; bool success = false; - std::string name = fileInfo[f].fullName; - std::string path = directories[d].ToString(); + Path name = fileInfo[f].fullName; + Path path = directories[d]; // Hack around Android VFS path bug. really need to redesign this. - if (name.substr(0, 7) == "assets/") - name = name.substr(7); - if (path.substr(0, 7) == "assets/") - path = path.substr(7); + if (name.ToString().substr(0, 7) == "assets/") + name = Path(name.ToString().substr(7)); + if (path.ToString().substr(0, 7) == "assets/") + path = Path(path.ToString().substr(7)); - if (ini.LoadFromVFS(name) || ini.Load(fileInfo[f].fullName)) { + if (ini.LoadFromVFS(name.ToString()) || ini.Load(fileInfo[f].fullName)) { success = true; // vsh load. meh. } + if (!success) continue; @@ -118,9 +119,9 @@ void LoadPostShaderInfo(const std::vector &directories) { section.Get("Parent", &info.parent, ""); section.Get("Visible", &info.visible, true); section.Get("Fragment", &temp, ""); - info.fragmentShaderFile = path + "/" + temp; + info.fragmentShaderFile = path / temp; section.Get("Vertex", &temp, ""); - info.vertexShaderFile = path + "/" + temp; + info.vertexShaderFile = path / temp; section.Get("OutputResolution", &info.outputResolution, false); section.Get("Upscaling", &info.isUpscalingFilter, false); section.Get("SSAA", &info.SSAAFilterLevel, 0); @@ -165,7 +166,7 @@ void LoadPostShaderInfo(const std::vector &directories) { section.Get("Name", &info.name, section.name().c_str()); section.Get("Compute", &temp, ""); section.Get("MaxScale", &info.maxScale, 255); - info.computeShaderFile = path + "/" + temp; + info.computeShaderFile = path / temp; appendTextureShader(info); } diff --git a/GPU/Common/PostShader.h b/GPU/Common/PostShader.h index b5c1f562f9..76c2e8ce6f 100644 --- a/GPU/Common/PostShader.h +++ b/GPU/Common/PostShader.h @@ -25,13 +25,13 @@ #include "Common/Data/Format/IniFile.h" struct ShaderInfo { - std::string iniFile; // which ini file was this definition in? So we can write settings back later + Path iniFile; // which ini file was this definition in? So we can write settings back later std::string section; // ini file section. This is saved. std::string name; // Fancy display name. std::string parent; // Parent shader ini section name. - std::string fragmentShaderFile; - std::string vertexShaderFile; + Path fragmentShaderFile; + Path vertexShaderFile; // Show this shader in lists (i.e. not just for chaining.) bool visible; @@ -65,11 +65,11 @@ struct ShaderInfo { }; struct TextureShaderInfo { - std::string iniFile; + Path iniFile; std::string section; std::string name; - std::string computeShaderFile; + Path computeShaderFile; int maxScale; bool operator == (const std::string &other) { diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 9c294a4f39..59590e8401 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -197,11 +197,13 @@ void PresentationCommon::CalculatePostShaderUniforms(int bufferWidth, int buffer uniforms->setting[3] = g_Config.mPostShaderSetting[shaderInfo->section + "SettingValue4"]; } -static std::string ReadShaderSrc(const std::string &filename) { +static std::string ReadShaderSrc(const Path &filename) { size_t sz = 0; + // TODO(scoped): VFS paths not handled well. char *data = (char *)VFSReadFile(filename.c_str(), &sz); - if (!data) + if (!data) { return ""; + } std::string src(data, sz); delete[] data; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index eff8a70e3d..fe386a215b 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -375,7 +375,7 @@ void TextureCacheVulkan::NotifyConfigChanged() { CompileScalingShader(); } -static std::string ReadShaderSrc(const std::string &filename) { +static std::string ReadShaderSrc(const Path &filename) { size_t sz = 0; char *data = (char *)VFSReadFile(filename.c_str(), &sz); if (!data) diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index e13f916c69..e91a719012 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -18,12 +18,10 @@ #include #include "Qt/QtHost.h" -std::string QtHost::SymbolMapFilename(std::string currentFilename) { - size_t dot = currentFilename.rfind('.'); - if (dot == std::string::npos) - currentFilename.append(".map"); +Path QtHost::SymbolMapFilename(Path currentFilename) { + std::string ext = currentFilename.GetFileExtension(); + if (ext == "") + return currentFilename.WithExtraExtension("map"); else - currentFilename.replace(dot, -1, ".map"); - - return currentFilename; + return currentFilename.WithReplacedExtension(ext, "map"); } diff --git a/Qt/QtHost.h b/Qt/QtHost.h index 2aa9bc1870..79a65caa68 100644 --- a/Qt/QtHost.h +++ b/Qt/QtHost.h @@ -65,14 +65,14 @@ public: } virtual bool AttemptLoadSymbolMap() override { auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); - return g_symbolMap->LoadSymbolMap(fn.c_str()); + return g_symbolMap->LoadSymbolMap(fn); } virtual void NotifySymbolMapUpdated() override { g_symbolMap->SortSymbols(); } void PrepareShutdown() { auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); - g_symbolMap->SaveSymbolMap(fn.c_str()); + g_symbolMap->SaveSymbolMap(fn); } void SetWindowTitle(const char *message) override { std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION; @@ -95,6 +95,6 @@ public: void NotifySwitchUMDUpdated() override {} private: - std::string SymbolMapFilename(std::string currentFilename); + Path SymbolMapFilename(Path currentFilename); MainWindow* mainWindow; }; diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index 964a61880d..247e270a20 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -156,13 +156,13 @@ void SaveStateActionFinished(SaveState::Status status, const std::string &messag void MainWindow::qlstateAct() { - std::string gamePath = PSP_CoreParameter().fileToStart; + std::string gamePath = PSP_CoreParameter().fileToStart.ToString(); SaveState::LoadSlot(gamePath, 0, SaveStateActionFinished, this); } void MainWindow::qsstateAct() { - std::string gamePath = PSP_CoreParameter().fileToStart; + std::string gamePath = PSP_CoreParameter().fileToStart.ToString(); SaveState::SaveSlot(gamePath, 0, SaveStateActionFinished, this); } @@ -177,7 +177,7 @@ void MainWindow::lstateAct() if (dialog.exec()) { QStringList fileNames = dialog.selectedFiles(); - SaveState::Load(fileNames[0].toStdString(), -1, SaveStateActionFinished, this); + SaveState::Load(Path(fileNames[0].toStdString()), -1, SaveStateActionFinished, this); } } @@ -192,7 +192,7 @@ void MainWindow::sstateAct() if (dialog.exec()) { QStringList fileNames = dialog.selectedFiles(); - SaveState::Save(fileNames[0].toStdString(), -1, SaveStateActionFinished, this); + SaveState::Save(Path(fileNames[0].toStdString()), -1, SaveStateActionFinished, this); } } @@ -276,7 +276,7 @@ void MainWindow::lmapAct() if (fileNames.count() > 0) { QString fileName = QFileInfo(fileNames[0]).absoluteFilePath(); - g_symbolMap->LoadSymbolMap(fileName.toStdString().c_str()); + g_symbolMap->LoadSymbolMap(Path(fileName.toStdString())); } } @@ -292,7 +292,7 @@ void MainWindow::smapAct() if (dialog.exec()) { fileNames = dialog.selectedFiles(); - g_symbolMap->SaveSymbolMap(fileNames[0].toStdString().c_str()); + g_symbolMap->SaveSymbolMap(Path(fileNames[0].toStdString())); } } @@ -311,7 +311,7 @@ void MainWindow::lsymAct() if (fileNames.count() > 0) { QString fileName = QFileInfo(fileNames[0]).absoluteFilePath(); - g_symbolMap->LoadNocashSym(fileName.toStdString().c_str()); + g_symbolMap->LoadNocashSym(Path(fileName.toStdString())); } } @@ -327,7 +327,7 @@ void MainWindow::ssymAct() if (dialog.exec()) { fileNames = dialog.selectedFiles(); - g_symbolMap->SaveNocashSym(fileNames[0].toStdString().c_str()); + g_symbolMap->SaveNocashSym(Path(fileNames[0].toStdString())); } } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 8f4ce144b4..9f558094e9 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -116,7 +116,7 @@ static bool IsTempPath(const Path &str) { class GameButton : public UI::Clickable { public: - GameButton(const std::string &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0) + GameButton(const Path &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0) : UI::Clickable(layoutParams), gridStyle_(gridStyle), gamePath_(gamePath) {} void Draw(UIContext &dc) override; @@ -418,14 +418,14 @@ std::string GameButton::DescribeText() const { class DirButton : public UI::Button { public: - DirButton(const std::string &path, bool gridStyle, UI::LayoutParams *layoutParams) - : UI::Button(path, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(false) {} - DirButton(const std::string &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0) + DirButton(const Path &path, bool gridStyle, UI::LayoutParams *layoutParams) + : UI::Button(path.ToString(), layoutParams), path_(path), gridStyle_(gridStyle), absolute_(false) {} + DirButton(const Path &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0) : UI::Button(text, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(true) {} virtual void Draw(UIContext &dc); - const std::string GetPath() const { + const Path &GetPath() const { return path_; } @@ -434,7 +434,7 @@ public: } private: - std::string path_; + Path path_; bool gridStyle_; bool absolute_; }; @@ -565,9 +565,12 @@ bool GameBrowser::DisplayTopBar() { return path_.GetPath() != "!RECENT"; } -bool GameBrowser::HasSpecialFiles(std::vector &filenames) { +bool GameBrowser::HasSpecialFiles(std::vector &filenames) { if (path_.GetPath() == "!RECENT") { - filenames = g_Config.recentIsos; + filenames.clear(); + for (auto &str : g_Config.recentIsos) { + filenames.push_back(Path(str)); + } return true; } return false; @@ -707,7 +710,7 @@ void GameBrowser::Refresh() { listingPending_ = !path_.IsListingReady(); - std::vector filenames; + std::vector filenames; if (HasSpecialFiles(filenames)) { for (size_t i = 0; i < filenames.size(); i++) { gameButtons.push_back(new GameButton(filenames[i], *gridStyle_, new UI::LinearLayoutParams(*gridStyle_ == true ? UI::WRAP_CONTENT : UI::FILL_PARENT, UI::WRAP_CONTENT))); @@ -757,14 +760,15 @@ void GameBrowser::Refresh() { if (browseFlags_ & BrowseFlags::NAVIGATE) { if (path_.CanNavigateUp()) { - gameList_->Add(new DirButton("..", *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))-> + gameList_->Add(new DirButton(Path(std::string("..")), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))-> OnClick.Handle(this, &GameBrowser::NavigateClick); } // Add any pinned paths before other directories. auto pinnedPaths = GetPinnedPaths(); for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) { - gameList_->Add(new DirButton(*it, GetBaseName(*it), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))-> + // TODO(scoped): Hmm + gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))-> OnClick.Handle(this, &GameBrowser::NavigateClick); } } @@ -814,7 +818,7 @@ bool GameBrowser::IsCurrentPathPinned() { return std::find(paths.begin(), paths.end(), File::ResolvePath(path_.GetPath())) != paths.end(); } -const std::vector GameBrowser::GetPinnedPaths() { +const std::vector GameBrowser::GetPinnedPaths() { #ifndef _WIN32 static const std::string sepChars = "/"; #else @@ -823,7 +827,7 @@ const std::vector GameBrowser::GetPinnedPaths() { const std::string currentPath = File::ResolvePath(path_.GetPath()); const std::vector paths = g_Config.vPinnedPaths; - std::vector results; + std::vector results; for (size_t i = 0; i < paths.size(); ++i) { // We want to exclude the current path, and its direct children. if (paths[i] == currentPath) { @@ -837,7 +841,7 @@ const std::vector GameBrowser::GetPinnedPaths() { } } - results.push_back(paths[i]); + results.push_back(Path(paths[i])); } return results; } @@ -891,7 +895,7 @@ UI::EventReturn GameBrowser::GameButtonHighlight(UI::EventParams &e) { UI::EventReturn GameBrowser::NavigateClick(UI::EventParams &e) { DirButton *button = static_cast(e.v); - std::string text = button->GetPath(); + std::string text = button->GetPath().ToString(); if (button->PathAbsolute()) { path_.SetPath(text); } else { diff --git a/UI/MainScreen.h b/UI/MainScreen.h index d9ecbe8ece..49ccae359a 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -19,6 +19,7 @@ #include +#include "Common/File/Path.h" #include "Common/UI/UIScreen.h" #include "Common/UI/ViewGroup.h" #include "UI/MiscScreens.h" @@ -55,13 +56,13 @@ public: protected: virtual bool DisplayTopBar(); - virtual bool HasSpecialFiles(std::vector &filenames); + virtual bool HasSpecialFiles(std::vector &filenames); void Refresh(); private: bool IsCurrentPathPinned(); - const std::vector GetPinnedPaths(); + const std::vector GetPinnedPaths(); const std::string GetBaseName(const std::string &path); UI::EventReturn GameButtonClick(UI::EventParams &e); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index aa864df336..5a1b4016db 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -511,11 +511,11 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch } } #elif PPSSPP_PLATFORM(IOS) - g_Config.memStickDirectory = user_data_path; - g_Config.flash0Directory = std::string(external_dir) + "/flash0/"; + g_Config.memStickDirectory = Path(user_data_path); + g_Config.flash0Directory = Path(std::string(external_dir)) / "flash0"; #elif PPSSPP_PLATFORM(SWITCH) - g_Config.memStickDirectory = g_Config.internalDataDirectory + "config/ppsspp/"; - g_Config.flash0Directory = g_Config.internalDataDirectory + "assets/flash0/"; + g_Config.memStickDirectory = Path(g_Config.internalDataDirectory) / "config/ppsspp"; + g_Config.flash0Directory = Path(g_Config.internalDataDirectory) / "assets/flash0"; #elif !PPSSPP_PLATFORM(WINDOWS) std::string config; if (getenv("XDG_CONFIG_HOME") != NULL) diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 418ce70012..ab7be8c776 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -243,7 +243,7 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort return false; } -static bool LoadGameList(const std::string &url, std::vector &games) { +static bool LoadGameList(const std::string &url, std::vector &games) { PathBrowser browser(url); std::vector files; browser.GetListing(files, "iso:cso:pbp:elf:prx:ppdmp:", &scanCancelled); @@ -498,7 +498,7 @@ void RemoteISOConnectScreen::ExecuteLoad() { class RemoteGameBrowser : public GameBrowser { public: - RemoteGameBrowser(const std::string &url, const std::vector &games, BrowseFlags browseFlags, bool *gridStyle_, ScreenManager* screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr) + RemoteGameBrowser(const std::string &url, const std::vector &games, 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(); @@ -509,18 +509,18 @@ protected: return false; } - bool HasSpecialFiles(std::vector &filenames) override; + bool HasSpecialFiles(std::vector &filenames) override; std::string url_; - std::vector games_; + std::vector games_; }; -bool RemoteGameBrowser::HasSpecialFiles(std::vector &filenames) { +bool RemoteGameBrowser::HasSpecialFiles(std::vector &filenames) { filenames = games_; return true; } -RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::vector &games) +RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::vector &games) : url_(url), games_(games) { } diff --git a/UI/RemoteISOScreen.h b/UI/RemoteISOScreen.h index 7eab2270e0..bfcac815be 100644 --- a/UI/RemoteISOScreen.h +++ b/UI/RemoteISOScreen.h @@ -76,18 +76,18 @@ protected: std::string host_; int port_; std::string url_; - std::vector games_; + std::vector games_; }; class RemoteISOBrowseScreen : public MainScreen { public: - RemoteISOBrowseScreen(const std::string &url, const std::vector &games); + RemoteISOBrowseScreen(const std::string &url, const std::vector &games); protected: void CreateViews() override; std::string url_; - std::vector games_; + std::vector games_; }; class RemoteISOSettingsScreen : public UIDialogScreenWithBackground { diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 6f5abfc5b2..3b237e2ca5 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -170,9 +170,9 @@ void SortedLinearLayout::Update() { class SavedataButton : public UI::Clickable { public: - SavedataButton(const std::string &gamePath, UI::LayoutParams *layoutParams = 0) + SavedataButton(const Path &gamePath, UI::LayoutParams *layoutParams = 0) : UI::Clickable(layoutParams), savePath_(gamePath) { - SetTag(gamePath); + SetTag(gamePath.ToString()); } void Draw(UIContext &dc) override; diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index b5a7e7b176..ee3e0342bf 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -97,9 +97,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptrLocalFolder->Path->Data(); - g_Config.memStickDirectory = ReplaceAll(ConvertWStringToUTF8(memstickFolderW), "\\", "/"); - if (g_Config.memStickDirectory.back() != '/') - g_Config.memStickDirectory += "/"; + g_Config.memStickDirectory = Path(ReplaceAll(ConvertWStringToUTF8(memstickFolderW), "\\", "/")); // On Win32 it makes more sense to initialize the system directories here // because the next place it was called was in the EmuThread, and it's too late by then. @@ -109,8 +107,8 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptrLoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap").c_str()); + bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap")); // Load the old-style map file. if (!result1) - result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".map").c_str()); - bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".sym").c_str()); + result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".map")); + bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".sym")); return result1 || result2; } void UWPHost::SaveSymbolMap() { - g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap").c_str()); + g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap")); } void UWPHost::NotifySymbolMapUpdated() { diff --git a/android/jni/TestRunner.cpp b/android/jni/TestRunner.cpp index 1e0636b15b..2c7e95fe80 100644 --- a/android/jni/TestRunner.cpp +++ b/android/jni/TestRunner.cpp @@ -59,7 +59,7 @@ static std::string TrimNewlines(const std::string &s) { bool TestsAvailable() { #if PPSSPP_PLATFORM(IOS) - Path testDirectory = Path(g_Config.flash0Directory) + "../"; + Path testDirectory = g_Config.flash0Directory / ".."; #else Path testDirectory = g_Config.memStickDirectory; #endif @@ -74,7 +74,7 @@ bool RunTests() { std::string output; #if PPSSPP_PLATFORM(IOS) - std::string baseDirectory = g_Config.flash0Directory + "../"; + Path baseDirectory = g_Config.flash0Directory / ".."; #else Path baseDirectory = g_Config.memStickDirectory; // Hack to easily run the tests on Windows from the submodule diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 96521ff2ae..28db565418 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -408,7 +408,7 @@ int main(int argc, const char* argv[]) #endif #if !defined(__ANDROID__) && !defined(_WIN32) - g_Config.memStickDirectory = std::string(getenv("HOME")) + "/.ppsspp/"; + g_Config.memStickDirectory = Path(std::string(getenv("HOME"))) / ".ppsspp"; #endif // Try to find the flash0 directory. Often this is from a subdirectory. diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index a1562a53fa..ee4dd2ead2 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -632,8 +632,8 @@ bool retro_load_game(const struct retro_game_info *game) g_Config.currentDirectory = retro_base_dir; g_Config.externalDirectory = retro_base_dir; - g_Config.memStickDirectory = retro_save_dir; - g_Config.flash0Directory = retro_base_dir + "flash0" DIR_SEP; + g_Config.memStickDirectory = Path(retro_save_dir); + g_Config.flash0Directory = Path(retro_base_dir) / "flash0"; g_Config.internalDataDirectory = retro_base_dir; VFSRegister("", new DirectoryAssetReader(retro_base_dir.c_str())); @@ -649,7 +649,7 @@ bool retro_load_game(const struct retro_game_info *game) CoreParameter coreParam = {}; coreParam.enableSound = true; - coreParam.fileToStart = std::string(game->path); + coreParam.fileToStart = Path(std::string(game->path)); coreParam.mountIso.clear(); coreParam.startBreak = false; coreParam.printfEmuLog = true;