From fcf09f10efabe9591e3e86fe28a0d7e02104534d Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 2 Dec 2016 22:12:00 -0500 Subject: [PATCH] more unicode fixes --- libretro-common/dynamic/dylib.c | 5 ++++- libretro-common/file/retro_stat.c | 10 ++++++++++ libretro-common/streams/file_stream.c | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libretro-common/dynamic/dylib.c b/libretro-common/dynamic/dylib.c index d73172ed1e..154a5458ed 100644 --- a/libretro-common/dynamic/dylib.c +++ b/libretro-common/dynamic/dylib.c @@ -76,7 +76,9 @@ dylib_t dylib_load(const char *path) lib = LoadLibrary(path_wide); - free(path_wide); + if (path_wide) + free(path_wide); + SetErrorMode(prevmode); if (!lib) @@ -84,6 +86,7 @@ dylib_t dylib_load(const char *path) set_dl_error(); return NULL; } + last_dyn_error[0] = 0; #else dylib_t lib = dlopen(path, RTLD_LAZY); diff --git a/libretro-common/file/retro_stat.c b/libretro-common/file/retro_stat.c index e918956f3b..a8b1282a1f 100644 --- a/libretro-common/file/retro_stat.c +++ b/libretro-common/file/retro_stat.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #if defined(_WIN32) @@ -196,7 +197,16 @@ bool mkdir_norecurse(const char *dir) { int ret; #if defined(_WIN32) +#ifdef _MSC_VER + CHAR_TO_WCHAR_ALLOC(dir, dir_wide) + + ret = _tmkdir(dir_wide); + + if (dir_wide) + free(dir_wide); +#else ret = _mkdir(dir); +#endif #elif defined(IOS) ret = mkdir(dir, 0755); #elif defined(VITA) || defined(PSP) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index f88131389a..531a4e91f5 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -27,6 +27,7 @@ #if defined(_WIN32) #include +#include # ifdef _MSC_VER # define setmode _setmode # endif @@ -210,7 +211,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len) { #ifdef _WIN32 CHAR_TO_WCHAR_ALLOC(path, path_wide) - stream->fp = _wfopen(path_wide, mode_str); + stream->fp = _tfopen(path_wide, mode_str); if (path_wide) free(path_wide);