aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-07-21 04:42:45 -0700
committerChris Robinson <[email protected]>2014-07-21 04:42:45 -0700
commit7b41ed7ec4bfb7e8ac3daef3eebc6831b96a8fa4 (patch)
tree513f34073bc3872216e824a6912b6798ffa2a6a4
parent0ff4a9144253a8b6dcaee62dde94ee255e5e879d (diff)
Check the current directory first for data files
-rw-r--r--Alc/helpers.c18
1 files changed, 16 insertions, 2 deletions
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')