From fb9cee4043b3b506e66fe7ffc9a71e13f2ffa15b Mon Sep 17 00:00:00 2001 From: "Andrei \"Akari\" Alexeyev" Date: Thu, 27 Apr 2017 11:27:48 +0300 Subject: [PATCH] TAISEI_RES_PATH and TAISEI_STORAGE_PATH env variables override resources and storage paths, respectively --- src/main.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index b5bb481d..ce50150c 100644 --- a/src/main.c +++ b/src/main.c @@ -100,15 +100,31 @@ static void init_sdl(void) { log_info("Using SDL %u.%u.%u", v.major, v.minor, v.patch); } -static void get_core_paths(char **res, char **storage) { +static char* get_default_res_path(void) { + char *res; + #ifdef RELATIVE - *res = SDL_GetBasePath(); - strappend(res, "data/"); + res = SDL_GetBasePath(); + strappend(&res, "data/"); #else - *res = strdup(STATIC_RESOURCE_PREFIX); + res = strdup(STATIC_RESOURCE_PREFIX); #endif - *storage = SDL_GetPrefPath("", "taisei"); + return res; +} + +static void get_core_paths(char **res, char **storage) { + if((*res = getenv("TAISEI_RES_PATH")) && **res) { + *res = strdup(*res); + } else { + *res = get_default_res_path(); + } + + if((*storage = getenv("TAISEI_STORAGE_PATH")) && **storage) { + *storage = strdup(*storage); + } else { + *storage = SDL_GetPrefPath("", "taisei"); + } } static void init_vfs(bool silent) {