mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
Allow specifying a root path for host0:/.
This way, similar to the PSP, we can have a root path outside the test.
This commit is contained in:
1 parent
b16d60f902
commit
63b5ec3d85
7 files changed
+73
-36
No files matched your search
@@ -185,6 +185,20 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string)
|
||||
return __KernelLoadExec(bootpath.c_str(), 0, error_string);
|
||||
}
|
||||
|
||||
static std::string NormalizePath(const std::string &path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char buf[512] = {0};
|
||||
if (GetFullPathNameA(path.c_str(), sizeof(buf) - 1, buf, NULL) == 0)
|
||||
return "";
|
||||
#else
|
||||
char buf[PATH_MAX + 1];
|
||||
if (realpath(path.c_str(), buf) == NULL)
|
||||
return "";
|
||||
#endif
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool Load_PSP_ELF_PBP(const char *filename, std::string *error_string)
|
||||
{
|
||||
// This is really just for headless, might need tweaking later.
|
||||
@@ -207,6 +221,25 @@ bool Load_PSP_ELF_PBP(const char *filename, std::string *error_string)
|
||||
path = ReplaceAll(path, "/", "\\");
|
||||
#endif
|
||||
|
||||
if (!PSP_CoreParameter().mountRoot.empty())
|
||||
{
|
||||
// We don't want to worry about .. and cwd and such.
|
||||
const std::string rootNorm = NormalizePath(PSP_CoreParameter().mountRoot + "/");
|
||||
const std::string pathNorm = NormalizePath(path + "/");
|
||||
|
||||
// If root is not a subpath of path, we can't boot the game.
|
||||
if (!startsWith(pathNorm, rootNorm))
|
||||
{
|
||||
*error_string = "Cannot boot ELF located outside mountRoot.";
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string filepath = ReplaceAll(pathNorm.substr(rootNorm.size()), "\\", "/");
|
||||
file = filepath + "/" + file;
|
||||
path = rootNorm;
|
||||
pspFileSystem.SetStartingDirectory(filepath);
|
||||
}
|
||||
|
||||
DirectoryFileSystem *fs = new DirectoryFileSystem(&pspFileSystem, path);
|
||||
pspFileSystem.Mount("umd0:", fs);
|
||||
|
||||
|
||||
Reference in new issue
Block a user