aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-12-08 19:17:59 -0800
committerChris Robinson <[email protected]>2015-12-08 19:17:59 -0800
commitf8a4ef6f514ad0accfc4fb7a05506f1879798b81 (patch)
treedec68402144e2fd017108bdae4299e133eb52d17
parentc08e975aa5760ce8b44c11a8a17d9e8214524570 (diff)
Use the ALSOFT_LOCAL_PATH env var instead of the CWD
-rw-r--r--Alc/helpers.c22
1 files 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);