aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c17
-rw-r--r--Alc/backends/wave.cpp16
-rw-r--r--Alc/compat.h5
-rw-r--r--Alc/helpers.c20
4 files changed, 26 insertions, 32 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 7d28b976..ae55e9b4 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -918,7 +918,22 @@ static void alc_initconfig(void)
str = getenv("ALSOFT_LOGFILE");
if(str && str[0])
{
- FILE *logfile = al_fopen(str, "wt");
+#ifdef _WIN32
+ FILE *logfile = NULL;
+ int len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
+ if(len > 0)
+ {
+ WCHAR *wname = calloc(sizeof(WCHAR), len);
+ if(wname)
+ {
+ MultiByteToWideChar(CP_UTF8, 0, str, -1, wname, len);
+ logfile = _wfopen(wname, L"wt");
+ free(wname);
+ }
+ }
+#else
+ FILE *logfile = fopen(str, "wt");
+#endif
if(logfile) LogFile = logfile;
else ERR("Failed to open log file '%s'\n", str);
}
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp
index 4f3947e5..ec67342a 100644
--- a/Alc/backends/wave.cpp
+++ b/Alc/backends/wave.cpp
@@ -223,10 +223,7 @@ static int ALCwaveBackend_mixerProc(void *ptr)
static ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name)
{
- ALCdevice *device;
- const char *fname;
-
- fname = GetConfigValue(nullptr, "wave", "file", "");
+ const char *fname{GetConfigValue(nullptr, "wave", "file", "")};
if(!fname[0]) return ALC_INVALID_VALUE;
if(!name)
@@ -234,14 +231,21 @@ static ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name)
else if(strcmp(name, waveDevice) != 0)
return ALC_INVALID_VALUE;
- self->mFile = al_fopen(fname, "wb");
+#ifdef _WIN32
+ {
+ std::wstring wname = utf8_to_wstr(fname);
+ self->mFile = _wfopen(wname.c_str(), L"wb");
+ }
+#else
+ self->mFile = fopen(fname, "wb");
+#endif
if(!self->mFile)
{
ERR("Could not open file '%s': %s\n", fname, strerror(errno));
return ALC_INVALID_VALUE;
}
- device = STATIC_CAST(ALCbackend, self)->mDevice;
+ ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice};
alstr_copy_cstr(&device->DeviceName, name);
return ALC_NO_ERROR;
diff --git a/Alc/compat.h b/Alc/compat.h
index 77845d73..15eca1d4 100644
--- a/Alc/compat.h
+++ b/Alc/compat.h
@@ -12,9 +12,6 @@ extern "C" {
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-/* Opens a file with standard I/O. The filename is expected to be UTF-8. */
-FILE *al_fopen(const char *fname, const char *mode);
-
#define HAVE_DYNLOAD 1
#ifdef __cplusplus
@@ -218,8 +215,6 @@ extern "C" {
#else
-#define al_fopen fopen
-
#if defined(HAVE_DLFCN_H)
#define HAVE_DYNLOAD 1
#endif
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 000b9576..064e03f5 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -429,26 +429,6 @@ void *GetSymbol(void *handle, const char *name)
return ret;
}
-FILE *al_fopen(const char *fname, const char *mode)
-{
- WCHAR *wname=NULL, *wmode=NULL;
- FILE *file = NULL;
-
- wname = FromUTF8(fname);
- wmode = FromUTF8(mode);
- if(!wname)
- ERR("Failed to convert UTF-8 filename: \"%s\"\n", fname);
- else if(!wmode)
- ERR("Failed to convert UTF-8 mode: \"%s\"\n", mode);
- else
- file = _wfopen(wname, wmode);
-
- free(wname);
- free(wmode);
-
- return file;
-}
-
void al_print(const char *type, const char *func, const char *fmt, ...)
{