Commit a95c40de authored by Bkg2k's avatar Bkg2k Committed by OyyoDams

Resolve "Root folder consistency"

parent 18c363f3
......@@ -10,6 +10,7 @@
#include <boost/asio/io_service.hpp>
#include <boost/make_shared.hpp>
#include <RecalboxConf.h>
#include <RootFolders.h>
std::vector<SystemData *> SystemData::sSystemVector;
......@@ -406,15 +407,15 @@ bool SystemData::loadConfig()
pt::ptree userDocument;
// Load user systems
bool userValid = loadSystemList(userDocument, systemMap, systemList, getUserConfigPath());
bool userValid = loadSystemList(userDocument, systemMap, systemList, getUserConfigurationAbsolutePath());
// Load template systems
bool templateValid = loadSystemList(templateDocument, systemMap, systemList, getTemplateConfigPath());
bool templateValid = loadSystemList(templateDocument, systemMap, systemList, getTemplateConfigurationAbsolutePath());
// Is there at least
if (!templateValid && !userValid)
{
LOG(LogError) << "No es_systems.cfg file available!";
writeExampleConfig(getUserConfigPath());
writeExampleConfig(getUserConfigurationAbsolutePath());
return false;
}
......@@ -498,7 +499,7 @@ void SystemData::writeExampleConfig(const std::string &path)
" <fullname>Nintendo Entertainment System</fullname>\n"
"\n"
" <!-- The path to start searching for ROMs in. '~' will be expanded to $HOME on Linux or %HOMEPATH% on Windows. -->\n"
" <path>~/roms/nes</path>\n"
" <path>/recalbox/share/roms/nes</path>\n"
"\n"
" <!-- A list of extensions to search for, delimited by any of the whitespace characters (\", \\r\\n\\t\").\n"
" You MUST include the period at the start of the extension! It's also case sensitive. -->\n"
......@@ -567,17 +568,6 @@ void SystemData::deleteSystems()
}
}
std::string SystemData::getUserConfigPath()
{
fs::path path = getHomePath() + mUserConfigurationRelativePath;
return path.generic_string();
}
std::string SystemData::getTemplateConfigPath()
{
return mTemplateConfigurationAbsolutePath;
}
std::string SystemData::getGamelistPath(bool forWrite) const
{
fs::path filePath;
......@@ -596,7 +586,7 @@ std::string SystemData::getGamelistPath(bool forWrite) const
}
}
// Unable to get or create directory in roms, fallback on ~
filePath = getHomePath() + "/.emulationstation/gamelists/" + mName + "/gamelist.xml";
filePath = RootFolders::DataRootFolder + "/system/.emulationstation/gamelists/" + mName + "/gamelist.xml";
fs::create_directories(filePath.parent_path());
return filePath.generic_string();
}
......
......@@ -9,6 +9,7 @@
#include "FileSorts.h"
#include <boost/property_tree/ptree.hpp>
#include <RootFolders.h>
class SystemData
{
......@@ -72,9 +73,6 @@ class SystemData
*/
static bool loadXmlFile(Tree& document, const std::string& filepath);
static constexpr const char* mUserConfigurationRelativePath = "/.emulationstation/es_systems.cfg";
static constexpr const char* mTemplateConfigurationAbsolutePath = "/etc/emulationstation/es_systems.cfg";
SystemData(const std::string& name, const std::string& fullName, const std::string& startPath,
const std::string& filteredExtensions, const std::string& command,
const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder,
......@@ -122,9 +120,6 @@ class SystemData
static bool loadConfig(); //Load the system config file at getConfigPath(). Returns true if no errors were encountered. An example will be written if the file doesn't exist.
static void writeExampleConfig(const std::string& path);
static std::string getUserConfigPath();
static std::string getTemplateConfigPath();
static std::vector<SystemData*> sSystemVector;
static SystemData *getFavoriteSystem();
static SystemData* getSystem(std::string& name);
......@@ -154,4 +149,7 @@ class SystemData
std::map<std::string, std::vector<std::string> *> * getEmulators();
std::vector<std::string> getCores(const std::string& emulatorName);
static std::string getUserConfigurationAbsolutePath() { return RootFolders::DataRootFolder + "/system/.emulationstation/es_systems.cfg"; }
static std::string getTemplateConfigurationAbsolutePath() { return RootFolders::TemplateRootFolder + "/system/.emulationstation/es_systems.cfg"; }
};
This diff is collapsed.
......@@ -4,6 +4,7 @@
#include <FreeImage.h>
#include <boost/filesystem.hpp>
#include <boost/assign.hpp>
#include <RootFolders.h>
#include "GamesDBScraper.h"
#include "MamedbScraper.h"
......@@ -283,7 +284,7 @@ std::string getSaveAsPath(const ScraperSearchParams& params, const std::string&
std::string path = params.system->getRootFolder()->getPath().generic_string() + "/downloaded_images/";
if(!boost::filesystem::exists(path) && !boost::filesystem::create_directory(path)){
// Unable to create the directory in system rom dir, fallback on ~
path = getHomePath() + "/.emulationstation/downloaded_images/" + subdirectory + "/";
path = RootFolders::DataRootFolder + "/system/.emulationstation/downloaded_images/" + subdirectory + "/";
}
if(!boost::filesystem::exists(path))
......
......@@ -19,6 +19,7 @@ set(CORE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/Sound.h
${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData.h
${CMAKE_CURRENT_SOURCE_DIR}/src/Timer.h
${CMAKE_CURRENT_SOURCE_DIR}/src/RootFolders.h
${CMAKE_CURRENT_SOURCE_DIR}/src/MenuThemeData.h
${CMAKE_CURRENT_SOURCE_DIR}/src/Util.h
${CMAKE_CURRENT_SOURCE_DIR}/src/Window.h
......@@ -90,6 +91,7 @@ set(CORE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/Sound.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Timer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RootFolders.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/MenuThemeData.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Util.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp
......
......@@ -9,6 +9,7 @@
#include "Settings.h"
#include "ThemeData.h"
#include "Locale.h"
#include "RootFolders.h"
#include <unistd.h>
#include <time.h>
#include <views/ViewController.h>
......@@ -294,11 +295,11 @@ void AudioManager::musicEnd()
void AudioManager::playCheckSound()
{
std::string selectedTheme = Settings::getInstance()->getString("ThemeSet");
std::string loadingMusic = getHomePath() + "/.emulationstation/themes/" + selectedTheme + "/fx/loading.ogg";
std::string loadingMusic = RootFolders::DataRootFolder + "/system/.emulationstation/themes/" + selectedTheme + "/fx/loading.ogg";
if (boost::filesystem::exists(loadingMusic) == false)
{
loadingMusic = "/recalbox/share_init/system/.emulationstation/themes/recalbox/fx/loading.ogg";
loadingMusic = RootFolders::TemplateRootFolder + "/system/.emulationstation/themes/recalbox/fx/loading.ogg";
}
if (boost::filesystem::exists(loadingMusic))
......
......@@ -8,6 +8,7 @@
#include <utility>
#include "platform.h"
#include "Settings.h"
#include "RootFolders.h"
#include "SDL.h"
#define KEYBOARD_GUID_STRING "-1"
......@@ -435,8 +436,7 @@ void InputManager::writeDeviceConfig(InputConfig* config)
std::string InputManager::getConfigPath()
{
std::string path = getHomePath();
path += "/.emulationstation/es_input.cfg";
std::string path = RootFolders::DataRootFolder + "/system/.emulationstation/es_input.cfg";
return path;
}
......
......@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <iostream>
#include "platform.h"
#include "RootFolders.h"
LogLevel Log::reportingLevel = LogInfo;
FILE* Log::file = NULL; //fopen(getLogPath().c_str(), "w");
......@@ -14,8 +15,8 @@ LogLevel Log::getReportingLevel()
std::string Log::getLogPath()
{
std::string home = getHomePath();
return home + "/.emulationstation/es_log.txt";
std::string home = RootFolders::DataRootFolder + "/system/.emulationstation/es_log.txt";
return home;
}
void Log::setReportingLevel(LogLevel level)
......
#include "RootFolders.h"
const std::string RootFolders::TemplateRootFolder = "/recalbox/share_init";
const std::string RootFolders::DataRootFolder = "/recalbox/share";
#pragma once
#include <string>
class RootFolders
{
public:
static const std::string TemplateRootFolder; // /recalbox/share_init
static const std::string DataRootFolder; // /recalbox/share
};
......@@ -2,6 +2,7 @@
#include "Log.h"
#include "pugixml/pugixml.hpp"
#include "platform.h"
#include "RootFolders.h"
#include <boost/filesystem.hpp>
#include <boost/assign.hpp>
......@@ -130,8 +131,9 @@ void saveMap(pugi::xml_node &node, std::map<K, V> &map, const char *type) {
}
}
void Settings::saveFile() {
const std::string path = getHomePath() + "/.emulationstation/es_settings.cfg";
void Settings::saveFile()
{
const std::string path = RootFolders::DataRootFolder + "/system/.emulationstation/es_settings.cfg";
pugi::xml_document doc;
......@@ -151,8 +153,9 @@ void Settings::saveFile() {
doc.save_file(path.c_str());
}
void Settings::loadFile() {
const std::string path = getHomePath() + "/.emulationstation/es_settings.cfg";
void Settings::loadFile()
{
const std::string path = RootFolders::DataRootFolder + "/system/.emulationstation/es_settings.cfg";
if (!boost::filesystem::exists(path))
return;
......
......@@ -11,6 +11,7 @@
#include "components/ImageComponent.h"
#include "components/TextComponent.h"
#include "RootFolders.h"
// This is a work around for some ambiguity that is introduced in C++11 that boost::assign::map_list_of leave open.
......@@ -601,7 +602,7 @@ const std::shared_ptr<ThemeData>& ThemeData::getDefault()
{
theme = std::shared_ptr<ThemeData>(new ThemeData());
const std::string path = getHomePath() + "/.emulationstation/es_theme_default.xml";
const std::string path = RootFolders::DataRootFolder + "/system/.emulationstation/es_theme_default.xml";
if(fs::exists(path))
{
try
......@@ -628,9 +629,10 @@ const std::shared_ptr<ThemeData>& ThemeData::getCurrent()
fs::path path;
std::string currentTheme = Settings::getInstance()->getString("ThemeSet");
static const size_t pathCount = 2;
fs::path paths[pathCount] = {
"/etc/emulationstation/themes/" + currentTheme,
getHomePath() + "/.emulationstation/themes/" + currentTheme
fs::path paths[pathCount] =
{
RootFolders::TemplateRootFolder + "/system/.emulationstation/themes/" + currentTheme,
RootFolders::DataRootFolder + "/system/.emulationstation/themes/" + currentTheme
};
......@@ -733,9 +735,10 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
std::map<std::string, ThemeSet> sets;
static const size_t pathCount = 2;
fs::path paths[pathCount] = {
"/etc/emulationstation/themes",
getHomePath() + "/.emulationstation/themes"
fs::path paths[pathCount] =
{
RootFolders::TemplateRootFolder + "/system/.emulationstation/themes",
RootFolders::DataRootFolder + "/system/.emulationstation/themes"
};
fs::directory_iterator end;
......@@ -764,11 +767,11 @@ std::map<std::string, std::string> ThemeData::getThemeSubSets(const std::string&
fs::path path;
std::deque<boost::filesystem::path> dequepath;
static const size_t pathCount = 2;
fs::path paths[pathCount] = {
"/etc/emulationstation/themes/" + theme,
getHomePath() + "/.emulationstation/themes/" + theme
fs::path paths[pathCount] =
{
RootFolders::TemplateRootFolder + "/system/.emulationstation/themes/" + theme,
RootFolders::DataRootFolder + "/system/.emulationstation/themes/" + theme
};
fs::directory_iterator end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment