mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
Improved the support for portable installations.
This commit is contained in:
parent
1478bbf550
commit
11ae6ba6f5
|
@ -48,6 +48,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <FreeImage.h>
|
#include <FreeImage.h>
|
||||||
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
@ -136,6 +137,46 @@ bool parseArgs(int argc, char* argv[])
|
||||||
win64ConsoleType consoleType = outputToConsole(false);
|
win64ConsoleType consoleType = outputToConsole(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::string portableFilePath = Utils::FileSystem::getExePath() + "/portable.txt";
|
||||||
|
|
||||||
|
// This is primarily intended for portable ES-DE installations on Windows (for example
|
||||||
|
// placed on a USB memory stick) but it may be usable for other operating systems too.
|
||||||
|
if (Utils::FileSystem::exists(portableFilePath)) {
|
||||||
|
std::cout << "Found portable.txt in the ES-DE executable directory\n";
|
||||||
|
std::ifstream portableFile;
|
||||||
|
std::string homePath;
|
||||||
|
#if defined(_WIN64)
|
||||||
|
portableFile.open(Utils::String::stringToWideString(portableFilePath).c_str());
|
||||||
|
#else
|
||||||
|
portableFile.open(portableFilePath.c_str());
|
||||||
|
#endif
|
||||||
|
if (!portableFile.fail()) {
|
||||||
|
std::string relativePath;
|
||||||
|
getline(portableFile, relativePath);
|
||||||
|
// If the file is empty, use the ES-DE executable directory as home.
|
||||||
|
if (relativePath == "")
|
||||||
|
homePath = Utils::FileSystem::getExePath();
|
||||||
|
else
|
||||||
|
homePath = Utils::FileSystem::getExePath() + "/" + relativePath;
|
||||||
|
|
||||||
|
#if defined(_WIN64)
|
||||||
|
homePath = Utils::String::replace(homePath, "/", "\\");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!Utils::FileSystem::exists(homePath)) {
|
||||||
|
std::cerr << "Error: Defined home path \"" << homePath << "\" does not exist\n";
|
||||||
|
}
|
||||||
|
else if (Utils::FileSystem::isRegularFile(homePath)) {
|
||||||
|
std::cerr << "Error: Defined home path \"" << homePath << "\" is a file\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "Setting home path to \"" << homePath << "\"\n";
|
||||||
|
Utils::FileSystem::setHomePath(homePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
portableFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
// We need to process --home before any call to Settings::getInstance(),
|
// We need to process --home before any call to Settings::getInstance(),
|
||||||
// because settings are loaded from the home path.
|
// because settings are loaded from the home path.
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
|
@ -359,8 +400,13 @@ bool checkApplicationHomeDirectory()
|
||||||
std::string home = Utils::FileSystem::getHomePath();
|
std::string home = Utils::FileSystem::getHomePath();
|
||||||
std::string applicationHome = home + "/.emulationstation";
|
std::string applicationHome = home + "/.emulationstation";
|
||||||
if (!Utils::FileSystem::exists(applicationHome)) {
|
if (!Utils::FileSystem::exists(applicationHome)) {
|
||||||
|
#if defined(_WIN64)
|
||||||
|
std::cout << "First startup, creating application home directory \"" <<
|
||||||
|
Utils::String::replace(applicationHome, "/", "\\") << "\"\n";
|
||||||
|
#else
|
||||||
std::cout << "First startup, creating application home directory \"" <<
|
std::cout << "First startup, creating application home directory \"" <<
|
||||||
applicationHome << "\"\n";
|
applicationHome << "\"\n";
|
||||||
|
#endif
|
||||||
Utils::FileSystem::createDirectory(applicationHome);
|
Utils::FileSystem::createDirectory(applicationHome);
|
||||||
if (!Utils::FileSystem::exists(applicationHome)) {
|
if (!Utils::FileSystem::exists(applicationHome)) {
|
||||||
std::cerr << "Fatal error: Couldn't create directory, permission problems?\n";
|
std::cerr << "Fatal error: Couldn't create directory, permission problems?\n";
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
<entry>C:\Program Files (x86)\RetroArch-Win64\retroarch.exe</entry>
|
<entry>C:\Program Files (x86)\RetroArch-Win64\retroarch.exe</entry>
|
||||||
<entry>C:\Program Files (x86)\RetroArch\retroarch.exe</entry>
|
<entry>C:\Program Files (x86)\RetroArch\retroarch.exe</entry>
|
||||||
<!-- Portable installation -->
|
<!-- Portable installation -->
|
||||||
|
<entry>%ESPATH%\RetroArch-Win64\retroarch.exe</entry>
|
||||||
|
<entry>%ESPATH%\RetroArch\retroarch.exe</entry>
|
||||||
<entry>%ESPATH%\..\RetroArch-Win64\retroarch.exe</entry>
|
<entry>%ESPATH%\..\RetroArch-Win64\retroarch.exe</entry>
|
||||||
<entry>%ESPATH%\..\RetroArch\retroarch.exe</entry>
|
<entry>%ESPATH%\..\RetroArch\retroarch.exe</entry>
|
||||||
</rule>
|
</rule>
|
||||||
|
@ -32,6 +34,7 @@
|
||||||
<rule type="staticpath">
|
<rule type="staticpath">
|
||||||
<entry>~\AppData\Local\yuzu\yuzu-windows-msvc\yuzu.exe</entry>
|
<entry>~\AppData\Local\yuzu\yuzu-windows-msvc\yuzu.exe</entry>
|
||||||
<!-- Portable installation -->
|
<!-- Portable installation -->
|
||||||
|
<entry>%ESPATH%\yuzu\yuzu-windows-msvc\yuzu.exe</entry>
|
||||||
<entry>%ESPATH%\..\yuzu\yuzu-windows-msvc\yuzu.exe</entry>
|
<entry>%ESPATH%\..\yuzu\yuzu-windows-msvc\yuzu.exe</entry>
|
||||||
</rule>
|
</rule>
|
||||||
</emulator>
|
</emulator>
|
||||||
|
|
Loading…
Reference in a new issue