Skip to content

Commit

Permalink
loader: add -cwd option to change working directory when app starts
Browse files Browse the repository at this point in the history
  • Loading branch information
AKuHAK committed Oct 19, 2024
1 parent c8c265f commit 1d32708
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Options:
- 5: IOP: Emulate DVD-DL
Multiple options possible, for example -gc=23
-cwd=<path> Change working directory
-cfg=<file> Load extra user/game specific config file (without .toml extension)
-dbc Enable debug colors
Expand Down
16 changes: 16 additions & 0 deletions ee/loader/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void print_usage()
printf(" - 5: IOP: Emulate DVD-DL\n");
printf(" Multiple options possible, for example -gc=23\n");
printf("\n");
printf(" -cwd=<path> Change working directory\n");
printf("\n");
printf(" -cfg=<file> Load extra user/game specific config file (without .toml extension)\n");
printf("\n");
printf(" -dbc Enable debug colors\n");
Expand Down Expand Up @@ -889,6 +891,18 @@ int main(int argc, char *argv[])
memset(&sys, 0, sizeof(struct SSystemSettings));
memset(&drv, 0, sizeof(struct SDriver));

/*
* Change working directory
*/
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "-cwd=", 5)) {
if (chdir(&argv[i][5]) != 0) {
printf("ERROR: failed to change working directory to %s\n", &argv[i][5]);
return -1;
}
}
}

/*
* Load system settings
*/
Expand Down Expand Up @@ -940,6 +954,8 @@ int main(int argc, char *argv[])
sys.sGC = &argv[i][4];
else if (!strncmp(argv[i], "-cfg=", 5))
sys.sCFGFile = &argv[i][5];
else if (!strncmp(argv[i], "-cwd=", 5))
continue;
else if (!strncmp(argv[i], "-dbc", 4))
sys.bDebugColors = true;
else if (!strncmp(argv[i], "-logo", 5))
Expand Down

0 comments on commit 1d32708

Please sign in to comment.