Setting back and forward slashes for paths based on os type.

This commit is contained in:
emb
2015-04-02 22:18:27 -05:00
parent db97532317
commit c87a6ef2b4
14 changed files with 155 additions and 79 deletions

View File

@@ -16,6 +16,7 @@
#include "CollectionInfo.h"
#include "Item.h"
#include "../Database/Configuration.h"
#include "../Utility/Utils.h"
#include <sstream>
#include <algorithm>
@@ -51,7 +52,7 @@ std::string CollectionInfo::GetName() const
std::string CollectionInfo::GetSettingsPath() const
{
return Configuration::GetAbsolutePath() + "/collections/" + GetName();
return Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", GetName());
}
std::string CollectionInfo::GetListPath() const

View File

@@ -47,22 +47,22 @@ CollectionInfoBuilder::~CollectionInfoBuilder()
bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
{
std::string collectionPath = Configuration::GetAbsolutePath() + "/collections/" + name;
std::string collectionPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", name);
std::vector<std::string> paths;
paths.push_back(collectionPath);
paths.push_back(collectionPath + "/medium_artwork");
paths.push_back(collectionPath + "/medium_artwork/artwork_back");
paths.push_back(collectionPath + "/medium_artwork/artwork_front");
paths.push_back(collectionPath + "/medium_artwork/bezel");
paths.push_back(collectionPath + "/medium_artwork/logo");
paths.push_back(collectionPath + "/medium_artwork/medium_back");
paths.push_back(collectionPath + "/medium_artwork/medium_front");
paths.push_back(collectionPath + "/medium_artwork/screenshot");
paths.push_back(collectionPath + "/medium_artwork/screentitle");
paths.push_back(collectionPath + "/medium_artwork/video");
paths.push_back(collectionPath + "/roms");
paths.push_back(collectionPath + "/system_artwork");
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "artwork_back"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "artwork_front"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "bezel"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "logo"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "medium_back"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "medium_front"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "screenshot"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "screentitle"));
paths.push_back(Utils::CombinePath(collectionPath, "medium_artwork", "video"));
paths.push_back(Utils::CombinePath(collectionPath, "roms"));
paths.push_back(Utils::CombinePath(collectionPath, "system_artwork"));
for(std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); it++)
{
@@ -89,7 +89,7 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
#endif
}
std::string filename = collectionPath + "/include.txt";
std::string filename = Utils::CombinePath(collectionPath, "include.txt");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream includeFile;
@@ -99,7 +99,7 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
includeFile << "# by settings.conf will be used" << std::endl;
includeFile.close();
filename = collectionPath + "/exclude.txt";
filename = Utils::CombinePath(collectionPath, "exclude.txt");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream excludeFile;
excludeFile.open(filename.c_str());
@@ -107,31 +107,31 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
includeFile << "# Add a list of files to hide on the menu (one filename per line, without the extension)." << std::endl;
excludeFile.close();
filename = collectionPath + "/settings.conf";
filename = Utils::CombinePath(collectionPath, "settings.conf");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream settingsFile;
settingsFile.open(filename.c_str());
settingsFile << "# Uncomment and edit the following line to use a different ROM path." << std::endl;
settingsFile << "#list.path = %BASE_ITEM_PATH%/%ITEM_COLLECTION_NAME%/roms" << std::endl;
settingsFile << "#list.path = " << Utils::CombinePath("%BASE_ITEM_PATH%", "%ITEM_COLLECTION_NAME%", "roms") << std::endl;
settingsFile << "list.includeMissingItems = false" << std::endl;
settingsFile << "list.extensions = zip" << std::endl;
settingsFile << "launcher = mame" << std::endl;
settingsFile << "metadata.type = MAME" << std::endl;
settingsFile << std::endl;
settingsFile << "#media.screenshot = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/screenshot" << std::endl;
settingsFile << "#media.screentitle = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/screentitle" << std::endl;
settingsFile << "#media.artwork_back = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/artwork_back" << std::endl;
settingsFile << "#media.artwork_front = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/artwork_front" << std::endl;
settingsFile << "#media.logo = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/logo" << std::endl;
settingsFile << "#media.medium_back = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/medium_back" << std::endl;
settingsFile << "#media.medium_front = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/medium_front" << std::endl;
settingsFile << "#media.screenshot = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/screenshot" << std::endl;
settingsFile << "#media.screentitle = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/screentitle" << std::endl;
settingsFile << "#media.video = %BASE_MEDIA_PATH%/%ITEM_COLLECTION_NAME%/medium_artwork/video" << std::endl;
settingsFile << "#media.screenshot = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.artwork_back = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_back") << std::endl;
settingsFile << "#media.artwork_front = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "artwork_front") << std::endl;
settingsFile << "#media.logo = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "logo") << std::endl;
settingsFile << "#media.medium_back = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_back") << std::endl;
settingsFile << "#media.medium_front = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "medium_front") << std::endl;
settingsFile << "#media.screenshot = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;
settingsFile << "#media.video = " << Utils::CombinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "video") << std::endl;
settingsFile.close();
filename = collectionPath + "/menu.xml";
filename = Utils::CombinePath(collectionPath, "menu.xml");
std::cout << "Creating file \"" << filename << "\"" << std::endl;
std::ofstream menuFile;
menuFile.open(filename.c_str());
@@ -234,8 +234,8 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
std::string path = info->GetListPath();
std::map<std::string, Item *> includeFilter;
std::map<std::string, Item *> excludeFilter;
std::string includeFile = Configuration::GetAbsolutePath() + "/collections/" + info->GetName() + "/include.txt";
std::string excludeFile = Configuration::GetAbsolutePath() + "/collections/" + info->GetName() + "/exclude.txt";
std::string includeFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", info->GetName(), "include.txt");
std::string excludeFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", info->GetName(), "exclude.txt");
std::string launcher;
bool showMissing = false;

View File

@@ -18,6 +18,7 @@
#include "CollectionInfo.h"
#include "Item.h"
#include "../Utility/Log.h"
#include "../Utility/Utils.h"
#include "../Database/Configuration.h"
#include "../Database/DB.h"
#include <algorithm>
@@ -43,7 +44,7 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection)
{
bool retVal = false;
//todo: magic string
std::string menuFilename = Configuration::GetAbsolutePath() + "/collections/" + collection->GetName() + "/menu.xml";
std::string menuFilename = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections", collection->GetName(), "menu.xml");
rapidxml::xml_document<> doc;
rapidxml::xml_node<> * rootNode;