From bf84945010c5011a8324f73316e0fa0655bd10ec Mon Sep 17 00:00:00 2001 From: Aloshi Date: Fri, 14 Jun 2013 10:16:16 -0500 Subject: [PATCH] Fixed XMLReader system path processing. getHomePath() now uses forward slash as a path separator on all platforms. --- src/XMLReader.cpp | 14 ++++++-------- src/platform.cpp | 4 ++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/XMLReader.cpp b/src/XMLReader.cpp index 3ccea64f0..d1e19b8ae 100644 --- a/src/XMLReader.cpp +++ b/src/XMLReader.cpp @@ -33,14 +33,12 @@ GameData* createGameFromPath(std::string gameAbsPath, SystemData* system) std::string sysPath = system->getStartPath(); //strip out the system path stuff so it's relative to the system root folder - for(unsigned int i = 0; i < gamePath.length(); i++) - { - if(gamePath[i] != sysPath[i]) - { - gamePath = gamePath.substr(i, gamePath.length() - i); - break; - } - } + unsigned int i = 0; + while(i < gamePath.length() && i < sysPath.length() && gamePath[i] == sysPath[i]) + i++; + + gamePath = gamePath.substr(i, gamePath.length() - i); + if(gamePath[0] != '/') gamePath.insert(0, "/"); diff --git a/src/platform.cpp b/src/platform.cpp index 33e7620e6..5690e5b9d 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -19,6 +19,10 @@ std::string getHomePath() if (envDir != nullptr && envPath != nullptr) { homePath = envDir; homePath += envPath; + + for(unsigned int i = 0; i < homePath.length(); i++) + if(homePath[i] == '\\') + homePath[i] = '/'; } } #else