From 6a59dad08cdc8e1cc39c294f2da45b3a1eec5e4c Mon Sep 17 00:00:00 2001 From: Mats Date: Wed, 15 Sep 2021 21:48:11 +0200 Subject: [PATCH] Add compile option to make unix use cwd as env (#12989) Setting UNIX_CWD_ENV to 1 when compiling with the unix platform will make the base path for the env the cwd. This is to be able to match the behavior on Windows. --- Makefile.common | 4 ++++ file_path_special.c | 3 +++ frontend/drivers/platform_unix.c | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index e91f0e4599..9071b8a29c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -188,6 +188,10 @@ endif ifeq ($(HAVE_UNIX), 1) OBJ += frontend/drivers/platform_unix.o + + ifeq ($(UNIX_CWD_ENV), 1) + DEF_FLAGS += -DRARCH_UNIX_CWD_ENV + endif endif ifeq ($(TARGET), retroarch_3ds) diff --git a/file_path_special.c b/file_path_special.c index b2d197ec25..7980ba1e70 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -107,6 +107,9 @@ bool fill_pathname_application_data(char *s, size_t len) "Library/Application Support/RetroArch", len); return true; } +#elif defined(RARCH_UNIX_CWD_ENV) + getcwd(s, len); + return true; #elif defined(DINGUX) dingux_get_base_path(s, len); return true; diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 70ec2d362c..e54d3d4d62 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1792,7 +1792,10 @@ static void frontend_unix_get_env(int *argc, } #else char base_path[PATH_MAX] = {0}; -#if defined(DINGUX) +#if defined(RARCH_UNIX_CWD_ENV) + /* The entire path is zero initialized. */ + base_path[0] = '.'; +#elif defined(DINGUX) dingux_get_base_path(base_path, sizeof(base_path)); #else const char *xdg = getenv("XDG_CONFIG_HOME");