From f8a4ef6f514ad0accfc4fb7a05506f1879798b81 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 8 Dec 2015 19:17:59 -0800 Subject: Use the ALSOFT_LOCAL_PATH env var instead of the CWD --- Alc/helpers.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Alc/helpers.c b/Alc/helpers.c index 25a47d88..3e8d9972 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -844,8 +844,17 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir) al_string path = AL_STRING_INIT_STATIC(); WCHAR *cwdbuf; - /* Search the CWD. */ - if(!(cwdbuf=_wgetcwd(NULL, 0))) + /* Search the app-local directory. */ + if((cwdbuf=_wgetenv(L"ALSOFT_LOCAL_PATH")) && *cwdbuf != '\0') + { + al_string_copy_wcstr(&path, cwdbuf); + if(is_slash(VECTOR_BACK(path))) + { + VECTOR_POP_BACK(path); + *VECTOR_ITER_END(path) = 0; + } + } + else if(!(cwdbuf=_wgetcwd(NULL, 0))) al_string_copy_cstr(&path, "."); else { @@ -1192,8 +1201,13 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir) const char *str, *next; char cwdbuf[PATH_MAX]; - // Search CWD - if(!getcwd(cwdbuf, sizeof(cwdbuf))) + /* Search the app-local directory. */ + if((str=getenv("ALSOFT_LOCAL_PATH")) && *str != '\0') + { + strncpy(cwdbuf, str, sizeof(cwdbuf)-1); + cwdbuf[sizeof(cwdbuf)-1] = '\0'; + } + else if(!getcwd(cwdbuf, sizeof(cwdbuf))) strcpy(cwdbuf, "."); RecurseDirectorySearch(cwdbuf, match, &results); -- cgit v1.2.3