mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-31 13:40:35 +00:00
Add log messages to fluid_fopen()
This commit is contained in:
parent
1cdeebef37
commit
ed34742824
1 changed files with 11 additions and 8 deletions
|
@ -225,43 +225,46 @@ void* fluid_alloc(size_t len)
|
|||
FILE *fluid_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
wchar_t *wpath, *wmode;
|
||||
FILE *file;
|
||||
wchar_t *wpath = NULL, *wmode = NULL;
|
||||
FILE *file = NULL;
|
||||
int length;
|
||||
if ((length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, NULL, 0)) == 0)
|
||||
{
|
||||
FLUID_LOG(FLUID_ERR, "Unable to perform MultiByteToWideChar() conversion for filename '%s'. Error was: '%s'", filename, fluid_get_windows_error());
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
wpath = FLUID_MALLOC(length * sizeof(wchar_t));
|
||||
if (wpath == NULL)
|
||||
{
|
||||
FLUID_LOG(FLUID_PANIC, "Out of memory.");
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, wpath, length);
|
||||
|
||||
if ((length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, mode, -1, NULL, 0)) == 0)
|
||||
{
|
||||
FLUID_FREE(wpath);
|
||||
FLUID_LOG(FLUID_ERR, "Unable to perform MultiByteToWideChar() conversion for mode '%s'. Error was: '%s'", mode, fluid_get_windows_error());
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
wmode = FLUID_MALLOC(length * sizeof(wchar_t));
|
||||
if (wmode == NULL)
|
||||
{
|
||||
FLUID_FREE(wpath);
|
||||
FLUID_LOG(FLUID_PANIC, "Out of memory.");
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
goto error_recovery;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, mode, -1, wmode, length);
|
||||
|
||||
file = _wfopen(wpath, wmode);
|
||||
|
||||
error_recovery:
|
||||
FLUID_FREE(wpath);
|
||||
FLUID_FREE(wmode);
|
||||
|
||||
|
|
Loading…
Reference in a new issue