From 4541c3e18b56dcc4fb417c1f53d730e8394686d5 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 19 Dec 2012 11:11:56 +0100 Subject: [PATCH] Slightly better logging in path mapping --- Core/FileSystems/MetaFileSystem.cpp | 21 +++++++++++---------- Core/FileSystems/MetaFileSystem.h | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 772b056bbf..6dae780398 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -18,7 +18,7 @@ #include #include "MetaFileSystem.h" -bool applyPathStringToComponentsVector(std::vector &vector, const std::string &pathString) +static bool ApplyPathStringToComponentsVector(std::vector &vector, const std::string &pathString) { size_t len = pathString.length(); size_t start = 0; @@ -63,7 +63,7 @@ bool applyPathStringToComponentsVector(std::vector &vector, const s * Changes relative paths to absolute, removes ".", "..", and trailing "/" * babel (and possibly other games) use "/directoryThatDoesNotExist/../directoryThatExists/filename" */ -bool RealPath(const std::string ¤tDirectory, const std::string &inPath, std::string &outPath) +static bool RealPath(const std::string ¤tDirectory, const std::string &inPath, std::string &outPath) { size_t inLen = inPath.length(); if (inLen == 0) @@ -152,7 +152,7 @@ bool RealPath(const std::string ¤tDirectory, const std::string &inPath, st else { const std::string curDirAfter = currentDirectory.substr(curDirColon + 1); - if (! applyPathStringToComponentsVector(cmpnts, curDirAfter) ) + if (! ApplyPathStringToComponentsVector(cmpnts, curDirAfter) ) { ERROR_LOG(HLE,"RealPath: currentDirectory is not a valid path: \"%s\"", currentDirectory.c_str()); return false; @@ -162,7 +162,7 @@ bool RealPath(const std::string ¤tDirectory, const std::string &inPath, st capacityGuess += currentDirectory.length(); } - if (! applyPathStringToComponentsVector(cmpnts, inAfter) ) + if (! ApplyPathStringToComponentsVector(cmpnts, inAfter) ) { DEBUG_LOG(HLE, "RealPath: inPath is not a valid path: \"%s\"", inPath.c_str()); return false; @@ -194,30 +194,31 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle) return 0; } -bool MetaFileSystem::MapFilePath(std::string inpath, std::string &outpath, IFileSystem **system) +bool MetaFileSystem::MapFilePath(const std::string &inpath, std::string &outpath, IFileSystem **system) { //TODO: implement current directory per thread (NOT per drive) //DEBUG_LOG(HLE, "MapFilePath: starting with \"%s\"", inpath.c_str()); - if ( RealPath(currentDirectory, inpath, inpath) ) + std::string realpath; + if ( RealPath(currentDirectory, inpath, realpath) ) { for (size_t i = 0; i < fileSystems.size(); i++) { size_t prefLen = fileSystems[i].prefix.size(); - if (fileSystems[i].prefix == inpath.substr(0, prefLen)) + if (fileSystems[i].prefix == realpath.substr(0, prefLen)) { - outpath = inpath.substr(prefLen); + outpath = realpath.substr(prefLen); *system = fileSystems[i].system; - DEBUG_LOG(HLE, "MapFilePath: mapped to prefix: \"%s\", path: \"%s\"", fileSystems[i].prefix.c_str(), outpath.c_str()); + DEBUG_LOG(HLE, "MapFilePath: mapped \"%s\" to prefix: \"%s\", path: \"%s\"", inpath.c_str(), fileSystems[i].prefix.c_str(), outpath.c_str()); return true; } } } - DEBUG_LOG(HLE, "MapFilePath: failed, returning false"); + DEBUG_LOG(HLE, "MapFilePath: failed mapping \"%s\", returning false", inpath.c_str()); return false; } diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index dee552e098..b0b63d9b97 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -37,7 +37,7 @@ public: void FreeHandle(u32 handle) {} IFileSystem *GetHandleOwner(u32 handle); - bool MapFilePath(std::string inpath, std::string &outpath, IFileSystem **system); + bool MapFilePath(const std::string &inpath, std::string &outpath, IFileSystem **system); std::vector GetDirListing(std::string path); u32 OpenFile(std::string filename, FileAccess access);