From 3c189b33c1c40797b1f28e81f844d9c8afae5073 Mon Sep 17 00:00:00 2001 From: Bim Overbohm Date: Wed, 3 Jul 2013 14:27:06 +0200 Subject: [PATCH] Convert paths to generic form after 341aa766d8c7af1923b7122a731ca0b2a809cbae Might not have caught all places where this should be done. --- src/SystemData.cpp | 8 ++++++-- src/XMLReader.cpp | 16 +++++++++++----- src/platform.cpp | 5 ++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/SystemData.cpp b/src/SystemData.cpp index a34ecf4e6..899cfe5e9 100644 --- a/src/SystemData.cpp +++ b/src/SystemData.cpp @@ -159,7 +159,7 @@ void SystemData::populateFolder(FolderData* folder) //add directories that also do not match an extension as folders if(!isGame && fs::is_directory(filePath)) { - FolderData* newFolder = new FolderData(this, filePath.string(), filePath.stem().string()); + FolderData* newFolder = new FolderData(this, filePath.generic_string(), filePath.stem().string()); populateFolder(newFolder); //ignore folders that do not contain games @@ -233,7 +233,11 @@ void SystemData::loadConfig() sysPath = varValue.substr(0, varValue.length() - 1); else sysPath = varValue; - }else if(varName == "EXTENSION") + //convert path to generic directory seperators + boost::filesystem::path genericPath(sysPath); + sysPath = genericPath.generic_string(); + } + else if(varName == "EXTENSION") sysExtension = varValue; else if(varName == "COMMAND") sysCommand = varValue; diff --git a/src/XMLReader.cpp b/src/XMLReader.cpp index d8a8f0eea..517ae8509 100644 --- a/src/XMLReader.cpp +++ b/src/XMLReader.cpp @@ -133,7 +133,9 @@ void parseGamelist(SystemData* system) continue; } - std::string path = pathNode.text().get(); + //convert path to generic directory seperators + boost::filesystem::path gamePath(pathNode.text().get()); + std::string path = gamePath.generic_string(); //expand "." if(path[0] == '.') @@ -169,7 +171,7 @@ void parseGamelist(SystemData* system) { newImage.erase(0, 1); boost::filesystem::path pathname(xmlpath); - newImage.insert(0, pathname.parent_path().string() ); + newImage.insert(0, pathname.parent_path().generic_string() ); } //if the image exist, set it @@ -218,7 +220,9 @@ void addGameDataNode(pugi::xml_node & parent, const GameData * game) //add values if (!game->getPath().empty()) { pugi::xml_node pathNode = newGame.append_child(GameData::xmlTagPath.c_str()); - pathNode.text().set(game->getPath().c_str()); + //store path with generic directory seperators + boost::filesystem::path gamePath(game->getPath()); + pathNode.text().set(gamePath.generic_string().c_str()); } if (!game->getName().empty()) { pugi::xml_node nameNode = newGame.append_child(GameData::xmlTagName.c_str()); @@ -294,8 +298,10 @@ void updateGamelist(SystemData* system) LOG(LogError) << "<" << GameData::xmlTagGame << "> node contains no <" << GameData::xmlTagPath << "> child!"; continue; } - //check path - if (pathNode.text().get() == game->getPath()) { + //check paths. use the same directory separators + boost::filesystem::path nodePath(pathNode.text().get()); + boost::filesystem::path gamePath(game->getPath()); + if (nodePath.generic_string() == gamePath.generic_string()) { //found the game. remove it. it will be added again later with updated values root.remove_child(gameNode); //break node search loop diff --git a/src/platform.cpp b/src/platform.cpp index 5690e5b9d..856161302 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -1,5 +1,6 @@ #include "platform.h" #include +#include std::string getHomePath() @@ -31,5 +32,7 @@ std::string getHomePath() } #endif - return homePath; + //convert path to generic directory seperators + boost::filesystem::path genericPath(homePath); + return genericPath.generic_string(); }