diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 67fdd124b6..ae3db8de1d 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -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 diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index 17eeb4ca5c..b54e153613 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -21,6 +21,20 @@ class MetaFileSystem : public IHandleAllocator, public IFileSystem { +private: + u32 current; + struct MountPoint + { + std::string prefix; + IFileSystem *system; + }; + std::vector fileSystems; + + typedef std::map 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 fileSystems; - - typedef std::map currentDir_t; - currentDir_t currentDir; - - std::string startingDirectory; };