From 6f6ea4595a1e1b17469a1b916be9969c6e8c4fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 18 Aug 2023 12:15:12 +0200 Subject: [PATCH] Windows: Split out Create... from InitSysDirectories, fixup uses --- Core/System.cpp | 13 +++++++------ Core/System.h | 2 ++ UWP/PPSSPP_UWPMain.cpp | 4 +++- Windows/main.cpp | 2 ++ headless/Headless.cpp | 11 ++++++++--- headless/WindowsHeadlessHost.h | 1 - 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index a3c401f109..bc8964e689 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -713,10 +713,9 @@ void InitSysDirectories() { if (!g_Config.memStickDirectory.empty() && !g_Config.flash0Directory.empty()) return; - const Path &path = File::GetExeDirectory(); - + const Path &exePath = File::GetExeDirectory(); // Mount a filesystem - g_Config.flash0Directory = path / "assets/flash0"; + g_Config.flash0Directory = exePath / "assets/flash0"; // Detect the "My Documents"(XP) or "Documents"(on Vista/7/8) folder. #if PPSSPP_PLATFORM(UWP) @@ -726,7 +725,7 @@ void InitSysDirectories() { // Caller sets this to the Documents folder. const Path rootMyDocsPath = g_Config.internalDataDirectory; const Path myDocsPath = rootMyDocsPath / "PPSSPP"; - const Path installedFile = path / "installed.txt"; + const Path installedFile = exePath / "installed.txt"; const bool installed = File::Exists(installedFile); // If installed.txt exists(and we can determine the Documents directory) @@ -751,7 +750,7 @@ void InitSysDirectories() { if (g_Config.memStickDirectory.empty()) g_Config.memStickDirectory = myDocsPath; } else { - g_Config.memStickDirectory = path / "memstick"; + g_Config.memStickDirectory = exePath / "memstick"; } // Create the memstickpath before trying to write to it, and fall back on Documents yet again @@ -773,7 +772,10 @@ void InitSysDirectories() { if (File::Exists(testFile)) File::Delete(testFile); #endif +} +#endif +void CreateSysDirectories() { // Create the default directories that a real PSP creates. Good for homebrew so they can // expect a standard environment. Skipping THEME though, that's pointless. File::CreateDir(GetSysDirectory(DIRECTORY_PSP)); @@ -788,4 +790,3 @@ void InitSysDirectories() { g_Config.currentDirectory = GetSysDirectory(DIRECTORY_GAME); } } -#endif diff --git a/Core/System.h b/Core/System.h index c90b84054e..8daad23755 100644 --- a/Core/System.h +++ b/Core/System.h @@ -110,6 +110,8 @@ Path GetSysDirectory(PSPDirectories directoryType); void InitSysDirectories(); #endif +void CreateSysDirectories(); + // RUNNING must be at 0, NEXTFRAME must be at 1. enum CoreState { // Emulation is running normally. diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 95ac55f4eb..16245a82ee 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -103,10 +103,12 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptrLocalFolder->Path->Data(); g_Config.internalDataDirectory = Path(internalDataFolderW); g_Config.memStickDirectory = g_Config.internalDataDirectory; + // Mount a filesystem + g_Config.flash0Directory = exePath / "assets/flash0"; // 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. - InitSysDirectories(); + CreateSysDirectories(); LogManager::Init(&g_Config.bEnableLogging); diff --git a/Windows/main.cpp b/Windows/main.cpp index caf52e7f45..963deff0a0 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -822,6 +822,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin // because the next place it was called was in the EmuThread, and it's too late by then. g_Config.internalDataDirectory = Path(W32Util::UserDocumentsPath()); InitSysDirectories(); + CreateSysDirectories(); // Check for the Vulkan workaround before any serious init. for (size_t i = 1; i < wideArgs.size(); ++i) { @@ -839,6 +840,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin } } + // Load config up here, because those changes below would be overwritten // if it's not loaded here first. g_Config.SetSearchPath(GetSysDirectory(DIRECTORY_SYSTEM)); diff --git a/headless/Headless.cpp b/headless/Headless.cpp index e8e3d83d9f..24c98e0201 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -499,17 +499,22 @@ int main(int argc, const char* argv[]) #if PPSSPP_PLATFORM(WINDOWS) g_Config.internalDataDirectory.clear(); - InitSysDirectories(); + + Path exePath = File::GetExeDirectory(); + // Mount a filesystem + g_Config.flash0Directory = exePath / "assets/flash0"; + g_Config.memStickDirectory = exePath / "memstick"; + File::CreateDir(g_Config.memStickDirectory); + CreateSysDirectories(); #endif - Path executablePath = File::GetExeDirectory(); #if !PPSSPP_PLATFORM(ANDROID) && !PPSSPP_PLATFORM(WINDOWS) g_Config.memStickDirectory = Path(std::string(getenv("HOME"))) / ".ppsspp"; g_Config.flash0Directory = executablePath / "assets/flash0"; #endif // Try to find the flash0 directory. Often this is from a subdirectory. - Path nextPath = executablePath; + Path nextPath = exePath; for (int i = 0; i < 5; ++i) { if (File::Exists(nextPath / "assets/flash0")) { g_Config.flash0Directory = nextPath / "assets/flash0"; diff --git a/headless/WindowsHeadlessHost.h b/headless/WindowsHeadlessHost.h index daa380b74d..5d5bd0d956 100644 --- a/headless/WindowsHeadlessHost.h +++ b/headless/WindowsHeadlessHost.h @@ -25,7 +25,6 @@ #include "Common/CommonWindows.h" -// TODO: Get rid of this junk class WindowsHeadlessHost : public HeadlessHost { public: