From 7b41ed7ec4bfb7e8ac3daef3eebc6831b96a8fa4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 21 Jul 2014 04:42:45 -0700 Subject: Check the current directory first for data files --- Alc/helpers.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'Alc') diff --git a/Alc/helpers.c b/Alc/helpers.c index f87b935c..28efc82e 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -433,12 +433,12 @@ FILE *OpenDataFile(const char *fname, const char *subdir) { static const int ids[2] = { CSIDL_APPDATA, CSIDL_COMMON_APPDATA }; WCHAR *wname=NULL, *wsubdir=NULL; + FILE *f; int i; /* If the path is absolute, open it directly. */ if(fname[0] != '\0' && fname[1] == ':' && is_slash(fname[2])) { - FILE *f; if((f=al_fopen(fname, "rb")) != NULL) { TRACE("Opened %s\n", fname); @@ -448,6 +448,14 @@ FILE *OpenDataFile(const char *fname, const char *subdir) return NULL; } + /* If it's relative, try the current directory first before the data directories. */ + if((f=al_fopen(fname, "rb")) != NULL) + { + TRACE("Opened %s\n", fname); + return f; + } + WARN("Could not open %s\n", fname); + wname = FromUTF8(fname); wsubdir = FromUTF8(subdir); if(!wname) @@ -458,7 +466,6 @@ FILE *OpenDataFile(const char *fname, const char *subdir) { WCHAR buffer[PATH_MAX]; size_t len; - FILE *f; if(SHGetSpecialFolderPathW(NULL, buffer, ids[i], FALSE) == FALSE) continue; @@ -505,6 +512,13 @@ FILE *OpenDataFile(const char *fname, const char *subdir) return NULL; } + if((f=al_fopen(fname, "rb")) != NULL) + { + TRACE("Opened %s\n", fname); + return f; + } + WARN("Could not open %s\n", fname); + if((str=getenv("XDG_DATA_HOME")) != NULL && str[0] != '\0') snprintf(buffer, sizeof(buffer), "%s/%s/%s", str, subdir, fname); else if((str=getenv("HOME")) != NULL && str[0] != '\0') -- cgit v1.2.3