Reintroduced the ES executable directory on Unix as a path to look for resources and themes.

This commit is contained in:
Leon Styhre 2020-07-12 12:47:39 +02:00
parent fe0e09ec7b
commit 29c50ff5a1
3 changed files with 56 additions and 22 deletions

View file

@ -4,8 +4,7 @@ EmulationStation Desktop Edition - Installation and configuration
**Note:** This is a quite technical document intended for those that are interested in compiling EmulationStation from source code, or would like to customize the configuration. If you just want to start using the software, check out the [User Guide](USERGUIDE.md) instead. **Note:** This is a quite technical document intended for those that are interested in compiling EmulationStation from source code, or would like to customize the configuration. If you just want to start using the software, check out the [User Guide](USERGUIDE.md) instead.
Development Environment ### Development Environment
=======================
EmulationStation-DE is developed and compiled using both Clang/LLVM and GCC on Unix, and GCC (MinGW) on Windows. I'm intending to get Clang/LLVM working on Windows as well. EmulationStation-DE is developed and compiled using both Clang/LLVM and GCC on Unix, and GCC (MinGW) on Windows. I'm intending to get Clang/LLVM working on Windows as well.
@ -137,19 +136,23 @@ Assuming the default installation prefix `/usr/local` has been used, this is the
/usr/local/share/emulationstation/themes /usr/local/share/emulationstation/themes
``` ```
**Note:** The resources directory is critical, without it the application won't start. ES will look in the following locations for the resources, in the listed order:
ES will look in the following locations for the resources:
* `[HOME]/.emulationstation/resources/` * `[HOME]/.emulationstation/resources/`
* `[INSTALL PREFIX]/share/emulationstation/resources/` * `[INSTALL PREFIX]/share/emulationstation/resources/`
* `[ES EXECUTABLE DIRECTORY]/resources/`
And it will look in the following locations for the themes: **Note:** The resources directory is critical, without it the application won't start.
And it will look in the following locations for the themes, also in the listed order:
* `[HOME]/.emulationstation/themes/` * `[HOME]/.emulationstation/themes/`
* `[INSTALL PREFIX]/share/emulationstation/themes/` * `[INSTALL PREFIX]/share/emulationstation/themes/`
* `[ES EXECUTABLE DIRECTORY]/themes/`
The home directory will always take precedence, so any resources or themes located there will override the ones in the installation path. The theme is not mandatory to start the application, but ES will be basically useless without it.
So the home directory will always take precedence, and any resources or themes located there will override the ones in the installation path or the path of the ES executable.
**Creating .deb and .rpm packages:** **Creating .deb and .rpm packages:**
@ -380,6 +383,24 @@ CPack: Create package
CPack: - package: C:/Programming/emulationstation-de/emulationstation-de-1.0.0-win64.exe generated. CPack: - package: C:/Programming/emulationstation-de/emulationstation-de-1.0.0-win64.exe generated.
``` ```
The default installation directory suggested by the installer is `C:\Program Files\EmulationStation`. However this can of course be changed by the user.
ES will look in the following locations for the resources, in the listed order:
* `[HOME]\.emulationstation\resources\`
* `[ES EXECUTABLE DIRECTORY]\resources\`
**Note:** The resources directory is critical, without it the application won't start.
And it will look in the following locations for the themes, also in the listed order:
* `[HOME]\.emulationstation\themes\`
* `[ES EXECUTABLE DIRECTORY]\themes\`
The theme is not mandatory to start the application, but ES will be basically useless without it.
So the home directory will always take precedence, and any resources or themes located there will override the ones in the path of the ES executable.
**Setting up a portable installation:** **Setting up a portable installation:**
It's possible to easily create a portable installation of ES for Windows, for example on a USB memory stick. It's possible to easily create a portable installation of ES for Windows, for example on a USB memory stick.

View file

@ -602,15 +602,16 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
{ {
std::map<std::string, ThemeSet> sets; std::map<std::string, ThemeSet> sets;
// Check for themes under the data installation directory for Unix or under the // Check for themes first under the home directory, then under the data installation
// executable directory for Windows, as well as under the user home directory regardless // directory (Unix only) and last under the ES executable directory.
// of operating system. #ifdef __unix__
static const size_t pathCount = 3;
#else
static const size_t pathCount = 2; static const size_t pathCount = 2;
std::string paths[pathCount] = #endif
{ std::string paths[pathCount] = {
#ifdef _WIN64
Utils::FileSystem::getExePath() + "/themes", Utils::FileSystem::getExePath() + "/themes",
#else #ifdef __unix__
Utils::FileSystem::getProgramDataPath() + "/themes", Utils::FileSystem::getProgramDataPath() + "/themes",
#endif #endif
Utils::FileSystem::getHomePath() + "/.emulationstation/themes" Utils::FileSystem::getHomePath() + "/.emulationstation/themes"

View file

@ -36,32 +36,44 @@ std::string ResourceManager::getResourcePath(const std::string& path) const
{ {
// Check if this is a resource file. // Check if this is a resource file.
if ((path[0] == ':') && (path[1] == '/')) { if ((path[0] == ':') && (path[1] == '/')) {
std::string testHome;
std::string testDataPath;
// Check under the home directory. // Check under the home directory.
std::string testHome;
testHome = Utils::FileSystem::getHomePath() + "/.emulationstation/resources/" + &path[2]; testHome = Utils::FileSystem::getHomePath() + "/.emulationstation/resources/" + &path[2];
if (Utils::FileSystem::exists(testHome)) if (Utils::FileSystem::exists(testHome))
return testHome; return testHome;
// Check for the resource under the data installation directory for Unix or under // Check under the data installation directory (Unix only).
// the executable directory for Windows. #ifdef __unix__
#ifdef _WIN64 std::string testDataPath;
testDataPath = Utils::FileSystem::getExePath() + "/resources/" + &path[2];
#else
testDataPath = Utils::FileSystem::getProgramDataPath() + "/resources/" + &path[2]; testDataPath = Utils::FileSystem::getProgramDataPath() + "/resources/" + &path[2];
#endif
if (Utils::FileSystem::exists(testDataPath)) { if (Utils::FileSystem::exists(testDataPath)) {
return testDataPath; return testDataPath;
} }
#endif
// Check under the ES executable directory.
std::string testExePath;
testExePath = Utils::FileSystem::getExePath() + "/resources/" + &path[2];
if (Utils::FileSystem::exists(testExePath)) {
return testExePath;
}
// For missing resources, log an error and terminate the application. This should // For missing resources, log an error and terminate the application. This should
// indicate that we have a broken EmulationStation installation. // indicate that we have a broken EmulationStation installation.
else { else {
LOG(LogError) << "Error - Program resource missing: " << path; LOG(LogError) << "Error - Program resource missing: " << path;
LOG(LogError) << "Tried to find the resource in the following locations:"; LOG(LogError) << "Tried to find the resource in the following locations:";
LOG(LogError) << testHome; LOG(LogError) << testHome;
#ifdef __unix__
LOG(LogError) << testDataPath; LOG(LogError) << testDataPath;
#endif
LOG(LogError) << testExePath;
LOG(LogError) << "Has EmulationStation been properly installed?"; LOG(LogError) << "Has EmulationStation been properly installed?";
Scripting::fireEvent("quit"); Scripting::fireEvent("quit");
emergencyShutdown(); emergencyShutdown();