mirror of https://github.com/xemu-project/xemu.git
settings: Read xemu.ini from binary path first
This commit is contained in:
parent
8326870f77
commit
d854a6c829
|
@ -21,7 +21,9 @@
|
||||||
#include <SDL_filesystem.h>
|
#include <SDL_filesystem.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "xemu-settings.h"
|
#include "xemu-settings.h"
|
||||||
#include "inih/ini.c" // FIXME
|
#include "inih/ini.c" // FIXME
|
||||||
|
@ -189,6 +191,20 @@ int xemu_settings_get_enum(enum xemu_settings_keys key, int *val)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool xemu_settings_detect_portable_mode(void)
|
||||||
|
{
|
||||||
|
bool val = false;
|
||||||
|
char *portable_path = g_strdup_printf("%s%s", SDL_GetBasePath(), filename);
|
||||||
|
FILE *tmpfile;
|
||||||
|
if ((tmpfile = fopen(portable_path, "r"))) {
|
||||||
|
fclose(tmpfile);
|
||||||
|
val = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(portable_path);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
const char *xemu_settings_get_path(void)
|
const char *xemu_settings_get_path(void)
|
||||||
{
|
{
|
||||||
if (settings_path != NULL) {
|
if (settings_path != NULL) {
|
||||||
|
@ -197,6 +213,13 @@ const char *xemu_settings_get_path(void)
|
||||||
|
|
||||||
char *base = SDL_GetPrefPath("xemu", "xemu");
|
char *base = SDL_GetPrefPath("xemu", "xemu");
|
||||||
assert(base != NULL);
|
assert(base != NULL);
|
||||||
|
|
||||||
|
// Check for xemu.ini in xemu binary directory, "portable mode"
|
||||||
|
if (xemu_settings_detect_portable_mode()) {
|
||||||
|
base = SDL_GetBasePath();
|
||||||
|
assert(base != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
size_t base_len = strlen(base);
|
size_t base_len = strlen(base);
|
||||||
|
|
||||||
size_t filename_len = strlen(filename);
|
size_t filename_len = strlen(filename);
|
||||||
|
@ -230,6 +253,13 @@ const char *xemu_settings_get_default_eeprom_path(void)
|
||||||
|
|
||||||
char *base = SDL_GetPrefPath("xemu", "xemu");
|
char *base = SDL_GetPrefPath("xemu", "xemu");
|
||||||
assert(base != NULL);
|
assert(base != NULL);
|
||||||
|
|
||||||
|
// Check for xemu.ini in xemu binary directory, "portable mode"
|
||||||
|
if (xemu_settings_detect_portable_mode()) {
|
||||||
|
base = SDL_GetBasePath();
|
||||||
|
assert(base != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
size_t base_len = strlen(base);
|
size_t base_len = strlen(base);
|
||||||
|
|
||||||
const char *name = "eeprom.bin";
|
const char *name = "eeprom.bin";
|
||||||
|
|
Loading…
Reference in New Issue