mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 13:36:24 +02:00
Merge pull request #402 from KentuckyCompass/chdir_bugfix
don't chop off prefix when mapping path for chdir
This commit is contained in:
commit
a808f08b3e
2 files changed
+33
-20
No files matched your search
@@ -162,7 +162,7 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system)
|
||||
bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, MountPoint **system)
|
||||
{
|
||||
std::string realpath;
|
||||
|
||||
@@ -197,7 +197,7 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
|
||||
if (strncasecmp(fileSystems[i].prefix.c_str(), realpath.c_str(), prefLen) == 0)
|
||||
{
|
||||
outpath = realpath.substr(prefLen);
|
||||
*system = fileSystems[i].system;
|
||||
*system = &(fileSystems[i]);
|
||||
|
||||
DEBUG_LOG(HLE, "MapFilePath: mapped \"%s\" to prefix: \"%s\", path: \"%s\"", inpath.c_str(), fileSystems[i].prefix.c_str(), outpath.c_str());
|
||||
|
||||
@@ -212,7 +212,7 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
|
||||
|
||||
void MetaFileSystem::Mount(std::string prefix, IFileSystem *system)
|
||||
{
|
||||
System x;
|
||||
MountPoint x;
|
||||
x.prefix=prefix;
|
||||
x.system=system;
|
||||
fileSystems.push_back(x);
|
||||
@@ -304,10 +304,10 @@ void MetaFileSystem::ChDir(const std::string &dir)
|
||||
int curThread = __KernelGetCurThread();
|
||||
|
||||
std::string of;
|
||||
IFileSystem *system;
|
||||
if (MapFilePath(dir, of, &system))
|
||||
MountPoint *mountPoint;
|
||||
if (MapFilePath(dir, of, &mountPoint))
|
||||
{
|
||||
currentDir[curThread] = of;
|
||||
currentDir[curThread] = mountPoint->prefix + of;
|
||||
//return true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -21,6 +21,20 @@
|
||||
|
||||
class MetaFileSystem : public IHandleAllocator, public IFileSystem
|
||||
{
|
||||
private:
|
||||
u32 current;
|
||||
struct MountPoint
|
||||
{
|
||||
std::string prefix;
|
||||
IFileSystem *system;
|
||||
};
|
||||
std::vector<MountPoint> fileSystems;
|
||||
|
||||
typedef std::map<int, std::string> currentDir_t;
|
||||
currentDir_t currentDir;
|
||||
|
||||
std::string startingDirectory;
|
||||
|
||||
public:
|
||||
MetaFileSystem()
|
||||
{
|
||||
@@ -40,7 +54,19 @@ public:
|
||||
virtual void DoState(PointerWrap &p);
|
||||
|
||||
IFileSystem *GetHandleOwner(u32 handle);
|
||||
bool MapFilePath(const std::string &inpath, std::string &outpath, IFileSystem **system);
|
||||
bool MapFilePath(const std::string &inpath, std::string &outpath, MountPoint **system);
|
||||
|
||||
inline bool MapFilePath(const std::string &_inpath, std::string &outpath, IFileSystem **system)
|
||||
{
|
||||
MountPoint *mountPoint;
|
||||
if (MapFilePath(_inpath, outpath, &mountPoint))
|
||||
{
|
||||
*system = mountPoint->system;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only possible if a file system is a DirectoryFileSystem or similar.
|
||||
bool GetHostPath(const std::string &inpath, std::string &outpath);
|
||||
@@ -70,17 +96,4 @@ public:
|
||||
void SetStartingDirectory(const std::string &dir) {
|
||||
startingDirectory = dir;
|
||||
}
|
||||
private:
|
||||
u32 current;
|
||||
struct System
|
||||
{
|
||||
std::string prefix;
|
||||
IFileSystem *system;
|
||||
};
|
||||
std::vector<System> fileSystems;
|
||||
|
||||
typedef std::map<int, std::string> currentDir_t;
|
||||
currentDir_t currentDir;
|
||||
|
||||
std::string startingDirectory;
|
||||
};
|
||||
Reference in new issue
Block a user