Windows: Split out Create... from InitSysDirectories, fixup uses

This commit is contained in:
Henrik Rydgård 2023-08-18 12:15:12 +02:00
parent 3f3c5edaff
commit 6f6ea4595a
6 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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.

View File

@ -103,10 +103,12 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
std::wstring internalDataFolderW = ApplicationData::Current->LocalFolder->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);

View File

@ -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));

View File

@ -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";

View File

@ -25,7 +25,6 @@
#include "Common/CommonWindows.h"
// TODO: Get rid of this junk
class WindowsHeadlessHost : public HeadlessHost
{
public: