aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcConfig.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-03-28 01:21:05 -0700
committerChris Robinson <[email protected]>2014-03-28 01:21:05 -0700
commit2ca673cca2205271fc1198e9bbf04695960cf25d (patch)
tree23bded92b3311a856cde7792a11712997d3f79d7 /Alc/alcConfig.c
parent20886059fd88724f724da8601a82e04fc3f03a53 (diff)
Properly handle special folder names with extended characters
Diffstat (limited to 'Alc/alcConfig.c')
-rw-r--r--Alc/alcConfig.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c
index 41416a18..34cf4d8f 100644
--- a/Alc/alcConfig.c
+++ b/Alc/alcConfig.c
@@ -291,27 +291,45 @@ static void LoadConfigFromFile(FILE *f)
free(buffer);
}
+#ifdef _WIN32
void ReadALConfig(void)
{
- char buffer[PATH_MAX];
- const char *str;
+ WCHAR buffer[PATH_MAX];
+ const WCHAR *str;
FILE *f;
-#ifdef _WIN32
- if(SHGetSpecialFolderPathA(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE)
+ if(SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE)
{
- size_t p = strlen(buffer);
- snprintf(buffer+p, sizeof(buffer)-p, "\\alsoft.ini");
+ size_t p = lstrlenW(buffer);
+ _snwprintf(buffer+p, PATH_MAX-p, L"\\alsoft.ini");
- TRACE("Loading config %s...\n", buffer);
- f = al_fopen(buffer, "rt");
+ TRACE("Loading config %ls...\n", buffer);
+ f = _wfopen(buffer, L"rt");
+ if(f)
+ {
+ LoadConfigFromFile(f);
+ fclose(f);
+ }
+ }
+
+ if((str=_wgetenv(L"ALSOFT_CONF")) != NULL && *str)
+ {
+ TRACE("Loading config %ls...\n", str);
+ f = _wfopen(str, L"rt");
if(f)
{
LoadConfigFromFile(f);
fclose(f);
}
}
+}
#else
+void ReadALConfig(void)
+{
+ char buffer[PATH_MAX];
+ const char *str;
+ FILE *f;
+
str = "/etc/openal/alsoft.conf";
TRACE("Loading config %s...\n", str);
@@ -388,7 +406,6 @@ void ReadALConfig(void)
fclose(f);
}
}
-#endif
if((str=getenv("ALSOFT_CONF")) != NULL && *str)
{
@@ -401,6 +418,7 @@ void ReadALConfig(void)
}
}
}
+#endif
void FreeALConfig(void)
{