mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-20 18:59:26 +02:00
[qt] fix relative ROM paths passed on the CLI on macOS (#4105)
On macOS, convert relative paths to absolute paths before changing the working directory. Otherwise, valid Switch formats may incorrectly fail with a "The ROM format is not supported" error. Fixes: https://github.com/eden-emulator/Issue-Reports/issues/404 Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4105 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: Samuel <lizzie@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
parent
7731b5bc86
commit
13d39f39aa
1 changed files with 16 additions and 0 deletions
|
|
@ -16,6 +16,12 @@
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <climits>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
@ -126,6 +132,16 @@ int main(int argc, char* argv[]) {
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
// Convert the relative path to an absolute path before the chdir
|
||||||
|
char resolved[PATH_MAX];
|
||||||
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
if (strcmp(argv[i], "-u") == 0 || strcmp(argv[i], "-input-profile") == 0) {
|
||||||
|
++i;
|
||||||
|
} else if (argv[i][0] != '-' && argv[i][0] != '/' && realpath(argv[i], resolved)) {
|
||||||
|
argv[i] = strdup(resolved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If you start a bundle (binary) on OSX without the Terminal, the working directory is "/".
|
// If you start a bundle (binary) on OSX without the Terminal, the working directory is "/".
|
||||||
// But since we require the working directory to be the executable path for the location of
|
// But since we require the working directory to be the executable path for the location of
|
||||||
// the user folder in the Qt Frontend, we need to cd into that working directory
|
// the user folder in the Qt Frontend, we need to cd into that working directory
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue