From 946b3d5746f5ed678d76f9410bb5a85ad0fd1613 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 6 Oct 2015 01:26:15 -0700 Subject: Try to use the full path for the CWD instead of . --- Alc/helpers.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'Alc/helpers.c') diff --git a/Alc/helpers.c b/Alc/helpers.c index b0da7b3d..dac29296 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -88,7 +88,9 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_FormFactor, 0x1da5d803, 0xd492, 0x4edd, 0x #include #endif -#ifdef _WIN32_IE +#ifndef _WIN32 +#include +#elif defined(_WIN32_IE) #include #endif @@ -764,8 +766,23 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir) } else { + al_string path = AL_STRING_INIT_STATIC(); + WCHAR *cwdbuf; + /* Search the CWD. */ - RecurseDirectorySearch(".", wmatch, &results); + if(!(cwdbuf=_wgetcwd(NULL, 0))) + al_string_copy_cstr(&path, "."); + else + { + al_string_copy_wcstr(&path, cwdbuf); + if(is_slash(VECTOR_BACK(path))) + { + VECTOR_POP_BACK(path); + *VECTOR_ITER_END(path) = 0; + } + free(cwdbuf); + } + RecurseDirectorySearch(al_string_get_cstr(path), wmatch, &results); /* Search the local and global data dirs. */ for(i = 0;i < COUNTOF(ids);i++) @@ -773,21 +790,19 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir) WCHAR buffer[PATH_MAX]; if(SHGetSpecialFolderPathW(NULL, buffer, ids[i], FALSE) != FALSE) { - al_string path = AL_STRING_INIT_STATIC(); al_string_copy_wcstr(&path, buffer); if(!is_slash(VECTOR_BACK(path))) al_string_append_char(&path, '\\'); al_string_append_cstr(&path, subdir); -#define FIX_SLASH(i) do { \ - if(*(i) == '/') *(i) = '\\'; \ -} while(0) +#define FIX_SLASH(i) do { if(*(i) == '/') *(i) = '\\'; } while(0) VECTOR_FOR_EACH(char, path, FIX_SLASH); #undef FIX_SLASH RecurseDirectorySearch(al_string_get_cstr(path), wmatch, &results); - al_string_deinit(&path); } } + + al_string_deinit(&path); } free(wmatch); @@ -1066,9 +1081,12 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir) { al_string path = AL_STRING_INIT_STATIC(); const char *str, *next; + char cwdbuf[PATH_MAX]; // Search CWD - RecurseDirectorySearch(".", match, &results); + if(!getcwd(cwdbuf, sizeof(cwdbuf))) + strcpy(cwdbuf, "."); + RecurseDirectorySearch(cwdbuf, match, &results); // Search local data dir if((str=getenv("XDG_DATA_HOME")) != NULL && str[0] != '\0') -- cgit v1.2.3