Merge with develop

This commit is contained in:
Don Honerbrink 2015-04-02 22:31:38 -05:00
commit 6f486a9468
15 changed files with 153 additions and 178 deletions

View File

@ -1,99 +0,0 @@
Linux Setup (x86 ubuntu)
===============================
Install ubuntu or xubuntu 14.04 (or newer)
0. Run the following command to install necessary dependencies
sudo apt-get install tortoisehg g++ cmake dos2unix zlib1g-dev libsdl2-2.0 libsdl2-mixer-2.0 libsdl2-image-2.0 libsdl2-ttf-2.0 \
libsdl2-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-ttf-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-good1.0-dev zlib1g-dev libglib2.0-0 libglib2.0-dev sqlite3
1. Obtain the source code by running the following command:
hg clone https://bitbucket.org/teamretro/retrofe
2. Generate your gcc make files with running the following command from inside the root folder of your setup:
cmake RetroFE/Source -BRetroFE/Build -DVERSION_MAJOR=0 -DVERSION_MINOR=0 -DVERSION_BUILD=0
3. Compile RetroFE and create a full environment by running the following commands:
cmake --build RetroFE/Build
python Scripts/Package.py --os=linux --build=full
4. Copy your live RetroFE system to any folder of your choosing. files can be found in Artifacts\linux\RetroFE
Linux Setup (Raspberry Pi running ubuntu)
===============================
Install raspbian
0. Run the following command to install necessary dependencies
sudo apt-get install tortoisehg g++ cmake dos2unix
1. Obtain the source code by running the following command:
hg clone https://bitbucket.org/teamretro/retrofe
2. Compile SDL2 by running the following command:
sudo Scripts/Raspi/install_sdl2_rpi.sh
3. Generate your gcc make files with running the following command from inside the root folder of your setup:
cmake RetroFE/Source -BRetroFE/Build -DVERSION_MAJOR=0 -DVERSION_MINOR=0 -DVERSION_BUILD=0
4. Compile RetroFE and create a full environment by running the following commands:
cmake --build RetroFE/Build
python Scripts/Package.py --os=linux --build=full
5. Copy your live RetroFE system to any folder of your choosing. files can be found in Artifacts\linux\RetroFE
Windows Setup
===============================
0. Setup libraries
Install Python 2.7
Install sphinx with python
Install visual studio 2012
Install Microsoft Windows SDK for Windows 7 and .net Framework 4 http://www.microsoft.com/en-us/download/details.aspx?id=8279
Install cmake
Install tortoisehg
Install 7zip
Install gstreamer and gstreamer-devel to c:/gstreamer(x86, not 64 bit!) from http://gstreamer.freedesktop/org/data/pkg/windows/1.4.0
1. Obtain the source code by running the following command:
hg clone https://bitbucket.org/teamretro/retrofe
2. Setup Environment
Run "RetroFE/Source/SetupEnvironment.bat" to setup necessary variables and paths to compile in visual studio
3. Generate your visual studio solution files with running the following command from inside the root folder of your setup:
cmake RetroFE/Source -BRetroFE/Build -DGSTREAMER_ROOT=C:/gstreamer/1.0/x86 -DVERSION_MAJOR=0 -DVERSION_MINOR=0 -DVERSION_BUILD=0
4. Compile RetroFE and create a full environment by running the following commands:
cmake --build RetroFE/Build --config Release
python Scripts\Package.py --os=windows --build=full --gstreamer_path=D:/gstreamer/1.0/x86
5. Copy your live RetroFE system to any folder of your choosing. files can be found in Artifacts\windows\RetroFE
Other build options
===============================
After compiling your code you can also build different environments:
1. To copy just the layouts to Artifacts/windows/RetroFE, run
python Scripts\Package.py --os=windows --build=layout --gstreamer_path=D:/gstreamer/1.0/x86
or
python Scripts\Package.py --os=linux --build=layout
2. To copy just retrofe.exe to Artifacts/windows/RetroFE, run
python Scripts\Package.py --os=windows --build=engine --gstreamer_path=D:/gstreamer/1.0/x86
or
python Scripts\Package.py --os=linux --build=engine
3. To copy just the third party dlls and retrofe to Artifacts/windows/RetroFE, run
python Scripts\Package.py --os=windows --build=core --gstreamer_path=D:/gstreamer/1.0/x86
or
python Scripts\Package.py --os=linux --build=core
4. To copy a whole live installation Artifacts/windows/RetroFE, run
python Scripts\Package.py --os=windows --build=full --gstreamer_path=D:/gstreamer/1.0/x86
or
python Scripts\Package.py --os=linux --build=full

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;

View File

@ -316,12 +316,11 @@ std::string Configuration::ConvertToAbsolutePath(std::string prefix, std::string
}
// check to see if it is already an absolute path
if((first != '/') &&
(first != '\\') &&
if((first != Utils::PathSeparator) &&
//(first != '.') &&
(second != ':'))
{
path = prefix + "/" + path;
path = Utils::CombinePath(prefix, path);
}
return path;
@ -360,36 +359,36 @@ void Configuration::GetMediaPropertyAbsolutePath(std::string collectionName, std
if(!GetPropertyAbsolutePath("baseMediaPath", baseMediaPath))
{
// base media path was not specified, assume media files are in the collection
baseMediaPath = GetAbsolutePath() + "/collections";
baseMediaPath = Utils::CombinePath(GetAbsolutePath(), "collections");
}
if(mediaType == "manufacturer")
{
value = baseMediaPath + "/_manufacturer";
value = Utils::CombinePath(baseMediaPath, "_manufacturer");
}
else if(mediaType == "genre")
{
value = baseMediaPath + "/_genre";
value = Utils::CombinePath(baseMediaPath, "_genre");
}
else if(mediaType == "year")
{
value = baseMediaPath + "/_year";
value = Utils::CombinePath(baseMediaPath, "_year");
}
else if(mediaType == "number_players")
{
value = baseMediaPath + "/_number_players";
value = Utils::CombinePath(baseMediaPath, "_number_players");
}
else if(mediaType == "number_buttons")
{
value = baseMediaPath + "/_number_buttons";
value = Utils::CombinePath(baseMediaPath, "_number_buttons");
}
else if(system)
{
value = baseMediaPath + "/" + collectionName + "/system_artwork";
value = Utils::CombinePath(baseMediaPath, collectionName, "system_artwork");
}
else
{
value = baseMediaPath + "/" + collectionName + "/medium_artwork/" + mediaType;
value = Utils::CombinePath(baseMediaPath, collectionName, "medium_artwork", mediaType);
}
}
@ -405,12 +404,11 @@ void Configuration::GetCollectionAbsolutePath(std::string collectionName, std::s
std::string baseItemPath;
if(GetPropertyAbsolutePath("baseItemPath", baseItemPath))
{
value = baseItemPath + "/" + collectionName;
value = Utils::CombinePath(baseItemPath, collectionName);
return;
}
value = GetAbsolutePath() + "/collections/" + collectionName + "/roms";
value = Utils::CombinePath(GetAbsolutePath(), "collections", collectionName, "roms");
}

View File

@ -110,8 +110,8 @@ bool MetadataDatabase::ImportDirectory()
{
DIR *dp;
struct dirent *dirp;
std::string hyperListPath = Configuration::GetAbsolutePath() + "/meta/hyperlist";
std::string mameListPath = Configuration::GetAbsolutePath() + "/meta/mamelist";
std::string hyperListPath = Utils::CombinePath(Configuration::GetAbsolutePath() + "meta", "hyperlist");
std::string mameListPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "meta", "mamelist");
dp = opendir(hyperListPath.c_str());
@ -135,7 +135,7 @@ bool MetadataDatabase::ImportDirectory()
if(extension == ".xml")
{
std::string importFile = hyperListPath + "/" + dirp->d_name;
std::string importFile = Utils::CombinePath(hyperListPath, std::string(dirp->d_name));
Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing hyperlist: " + importFile);
ImportHyperList(importFile, collectionName);
}
@ -167,7 +167,7 @@ bool MetadataDatabase::ImportDirectory()
if(extension == ".xml")
{
std::string importFile = mameListPath + "/" + dirp->d_name;
std::string importFile = Utils::CombinePath(mameListPath, std::string(dirp->d_name));
Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing mamelist: " + importFile);
Config.SetStatus("Scraping data from " + importFile);
ImportMameList(importFile, collectionName);

View File

@ -116,9 +116,9 @@ std::string Launcher::ReplaceVariables(std::string str,
str = Utils::Replace(str, "%ITEM_COLLECTION_NAME%", itemCollectionName);
str = Utils::Replace(str, "%RETROFE_PATH%", Configuration::GetAbsolutePath());
#ifdef WIN32
str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Configuration::GetAbsolutePath() + "/RetroFE.exe");
str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Utils::CombinePath(Configuration::GetAbsolutePath(), "RetroFE.exe"));
#else
str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Configuration::GetAbsolutePath() + "/RetroFE");
str = Utils::Replace(str, "%RETROFE_EXEC_PATH%", Utils::CombinePath(Configuration::GetAbsolutePath(), "RetroFE"));
#endif
return str;
@ -153,7 +153,7 @@ bool Launcher::ExecuteCommand(std::string executable, std::string args, std::str
if(!CreateProcess(NULL, applicationName, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, currDir, &startupInfo, &processInfo))
#else
const std::size_t last_slash_idx = executable.rfind("/");
const std::size_t last_slash_idx = executable.rfind(Utils::PathSeparator);
if (last_slash_idx != std::string::npos)
{
std::string applicationName = executable.substr(last_slash_idx + 1);
@ -275,7 +275,7 @@ bool Launcher::GetCollectionDirectory(std::string &directory, std::string collec
// find the items path folder (i.e. ROM path)
Config.GetCollectionAbsolutePath(collection, itemsPathValue);
directory += itemsPathValue + "/";
directory += itemsPathValue + Utils::PathSeparator;
return true;
}

View File

@ -30,7 +30,7 @@ Image * ImageBuilder::CreateImage(std::string path, std::string name, float scal
extensions.push_back("jpeg");
extensions.push_back("JPEG");
std::string prefix = path + "/" + name;
std::string prefix = Utils::CombinePath(path, name);
std::string file;
if(Utils::FindMatchingFile(prefix, extensions, file))

View File

@ -31,7 +31,7 @@ VideoComponent * VideoBuilder::CreateVideo(std::string path, std::string name, f
extensions.push_back("avi");
extensions.push_back("AVI");
std::string prefix = path + "/" + name;
std::string prefix = Utils::CombinePath(path, name);
std::string file;
if(Utils::FindMatchingFile(prefix, extensions, file))

View File

@ -77,8 +77,8 @@ Page *PageBuilder::BuildPage()
std::string layoutFile;
std::string layoutName = LayoutKey;
LayoutPath = Configuration::GetAbsolutePath() + "/layouts/" + layoutName;
layoutFile = LayoutPath + "/" + LayoutPage + ".xml";
LayoutPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "layouts", layoutName);
layoutFile = Utils::CombinePath(LayoutPath, LayoutPage + ".xml");
Logger::Write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile);
@ -125,7 +125,7 @@ Page *PageBuilder::BuildPage()
if(fontXml)
{
FontName = Config.ConvertToAbsolutePath(
Config.GetAbsolutePath() + "/layouts/" + LayoutKey + "/",
Utils::CombinePath(Config.GetAbsolutePath(), "layouts", LayoutKey, ""),
fontXml->value());
}
@ -345,12 +345,7 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
else
{
std::string imagePath;
imagePath = Configuration::ConvertToAbsolutePath(LayoutPath, imagePath);
imagePath.append("/");
imagePath.append(src->value());
imagePath = Utils::CombinePath(Configuration::ConvertToAbsolutePath(LayoutPath, imagePath), std::string(src->value()));
Image *c = new Image(imagePath, ScaleX, ScaleY);
ViewInfo *v = c->GetBaseViewInfo();
@ -508,7 +503,7 @@ Font *PageBuilder::AddFont(xml_node<> *component, xml_node<> *defaults)
if(fontXml)
{
fontName = Config.ConvertToAbsolutePath(
Config.GetAbsolutePath() + "/layouts/" + LayoutKey + "/",
Utils::CombinePath(Config.GetAbsolutePath(), "layouts", LayoutKey,""),
fontXml->value());
Logger::Write(Logger::ZONE_DEBUG, "Layout", "loading font " + fontName );

View File

@ -73,20 +73,22 @@ int main(int argc, char **argv)
bool ImportConfiguration(Configuration *c)
{
std::string configPath = Configuration::GetAbsolutePath();
std::string launchersPath = Configuration::GetAbsolutePath() + "/launchers";
std::string collectionsPath = Configuration::GetAbsolutePath() + "/collections";
std::string launchersPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "launchers");
std::string collectionsPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "collections");
DIR *dp;
struct dirent *dirp;
if(!c->Import("", configPath + "/settings.conf"))
std::string settingsConfPath = Utils::CombinePath(configPath, "settings.conf");
if(!c->Import("", settingsConfPath))
{
Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + configPath + "/settings.conf\"");
Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + settingsConfPath + "\"");
return false;
}
if(!c->Import("controls", configPath + "/controls.conf"))
std::string controlsConfPath = Utils::CombinePath(configPath, "controls.conf");
if(!c->Import("controls", controlsConfPath))
{
Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + configPath + "/settings.conf\"");
Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + controlsConfPath + "\"");
return false;
}
@ -111,7 +113,7 @@ bool ImportConfiguration(Configuration *c)
{
std::string prefix = "launchers." + basename;
std::string importFile = launchersPath + "/" + std::string(dirp->d_name);
std::string importFile = Utils::CombinePath(launchersPath, std::string(dirp->d_name));
if(!c->Import(prefix, importFile))
{
@ -140,7 +142,7 @@ bool ImportConfiguration(Configuration *c)
{
std::string prefix = "collections." + std::string(dirp->d_name);
std::string settingsFile = collectionsPath + "/" + dirp->d_name + "/settings.conf";
std::string settingsFile = Utils::CombinePath(collectionsPath, std::string(dirp->d_name), "settings.conf");
if(!c->Import(prefix, settingsFile))
{
@ -160,7 +162,7 @@ bool ImportConfiguration(Configuration *c)
bool StartLogging()
{
std::string logFile = Configuration::GetAbsolutePath() + "/log.txt";
std::string logFile = Utils::CombinePath(Configuration::GetAbsolutePath(), "log.txt");
if(!Logger::Initialize(logFile))
{

View File

@ -21,6 +21,7 @@
#include "Collection/Item.h"
#include "Execute/Launcher.h"
#include "Utility/Log.h"
#include "Utility/Utils.h"
#include "Collection/MenuParser.h"
#include "SDL.h"
#include "Control/UserInput.h"
@ -84,7 +85,7 @@ int RetroFE::Initialize(void *context)
return -1;
}
instance->Db = new DB(Configuration::GetAbsolutePath() + "/meta.db");
instance->Db = new DB(Utils::CombinePath(Configuration::GetAbsolutePath(), "meta.db"));
if(!instance->Db->Initialize())
{

View File

@ -22,6 +22,7 @@
#include <fstream>
#include <dirent.h>
#include <locale>
#include <list>
Utils::Utils()
@ -54,6 +55,66 @@ std::string Utils::UppercaseFirst(std::string str)
return str;
}
std::string Utils::CombinePath(std::list<std::string> &paths)
{
std::list<std::string>::iterator it = paths.begin();
std::string path;
if(it != paths.end())
{
path += *it;
it++;
}
while(it != paths.end())
{
path += Utils::PathSeparator;
path += *it;
it++;
}
return path;
}
std::string Utils::CombinePath(std::string path1, std::string path2)
{
std::list<std::string> paths;
paths.push_back(path1);
paths.push_back(path2);
return CombinePath(paths);
}
std::string Utils::CombinePath(std::string path1, std::string path2, std::string path3)
{
std::list<std::string> paths;
paths.push_back(path1);
paths.push_back(path2);
paths.push_back(path3);
return CombinePath(paths);
}
std::string Utils::CombinePath(std::string path1, std::string path2, std::string path3, std::string path4)
{
std::list<std::string> paths;
paths.push_back(path1);
paths.push_back(path2);
paths.push_back(path3);
paths.push_back(path4);
return CombinePath(paths);
}
std::string Utils::CombinePath(std::string path1, std::string path2, std::string path3, std::string path4, std::string path5)
{
std::list<std::string> paths;
paths.push_back(path1);
paths.push_back(path2);
paths.push_back(path3);
paths.push_back(path4);
paths.push_back(path5);
return CombinePath(paths);
}
bool Utils::FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file)
{
for(unsigned int i = 0; i < extensions.size(); ++i)

View File

@ -17,7 +17,7 @@
#include <string>
#include <vector>
#include <list>
class Utils
{
public:
@ -34,6 +34,20 @@ public:
static bool FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file);
static std::string ToLower(std::string str);
static std::string UppercaseFirst(std::string str);
//todo: there has to be a better way to do this
static std::string CombinePath(std::list<std::string> &paths);
static std::string CombinePath(std::string path1, std::string path2);
static std::string CombinePath(std::string path1, std::string path2, std::string path3);
static std::string CombinePath(std::string path1, std::string path2, std::string path3, std::string path4);
static std::string CombinePath(std::string path1, std::string path2, std::string path3, std::string path4, std::string path5);
#ifdef WIN32
static const char PathSeparator = '\\';
#else
static const char PathSeparator = '/';
#endif
private:
Utils();
virtual ~Utils();

View File

@ -18,6 +18,7 @@
#include "../Graphics/Component/Image.h"
#include "../Database/Configuration.h"
#include "../Utility/Log.h"
#include "../Utility/Utils.h"
#include "../SDL.h"
#include <sstream>
#include <cstring>
@ -134,7 +135,7 @@ bool GStreamerVideo::Initialize()
return true;
}
std::string path = Configuration::GetAbsolutePath() + "/Core";
std::string path = Utils::CombinePath(Configuration::GetAbsolutePath(), "Core");
gst_init(NULL, NULL);
#ifdef WIN32