all repos — mgba @ 5bae2087feddeef3345d19b53f7a1e6fcd7b4f62

mGBA Game Boy Advance Emulator

All: Proper handling of Unicode file paths
Jeffrey Pfau jeffrey@endrift.com
Mon, 29 Jun 2015 21:45:32 -0700
commit

5bae2087feddeef3345d19b53f7a1e6fcd7b4f62

parent

99878b32cab881ef8163017322e545806bae0aaa

4 files changed, 18 insertions(+), 6 deletions(-)

jump to
M CHANGESCHANGES

@@ -91,6 +91,7 @@ - GBA: Don't include GBACLIDebugger struct unless needed

- SDL: Clean up GL context - GBA Audio: Implement audio reset for channels A/B - GBA Hardware: Backport generic RTC source into core + - All: Proper handling of Unicode file paths 0.2.1: (2015-05-13) Bugfixes:
M src/gba/supervisor/config.csrc/gba/supervisor/config.c

@@ -133,10 +133,15 @@ mkdir(out, 0755);

snprintf(out, outLength, "%s/.config/%s", home, binaryName); mkdir(out, 0755); #else - char home[MAX_PATH]; - SHGetFolderPath(0, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, home); - snprintf(out, outLength, "%s\\%s", home, projectName); - CreateDirectoryA(out, NULL); + wchar_t* home; + wchar_t wpath[MAX_PATH]; + wchar_t wprojectName[MAX_PATH]; + SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &home); + MultiByteToWideChar(CP_UTF8, 0, projectName, -1, wprojectName, MAX_PATH); + StringCchPrintfW(wpath, MAX_PATH, L"%ws\\%ws", home, wprojectName); + CoTaskMemFree(home); + CreateDirectoryW(wpath, NULL); + WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, outLength, 0, 0); #endif }
M src/platform/qt/VFileDevice.cppsrc/platform/qt/VFileDevice.cpp

@@ -27,5 +27,5 @@ return m_vf->size(m_vf);

} VFile* VFileDevice::open(QString path, int mode) { - return VFileOpen(path.toLocal8Bit().constData(), mode); + return VFileOpen(path.toUtf8().constData(), mode); }
M src/util/vfs/vfs-fd.csrc/util/vfs/vfs-fd.c

@@ -9,6 +9,8 @@ #include <fcntl.h>

#include <sys/stat.h> #ifndef _WIN32 #include <sys/mman.h> +#else +#include <windows.h> #endif struct VFileFD {

@@ -35,8 +37,12 @@ return 0;

} #ifdef _WIN32 flags |= O_BINARY; -#endif + wchar_t wpath[PATH_MAX]; + MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, sizeof(wpath) / sizeof(*wpath)); + int fd = _wopen(wpath, flags, 0666); +#else int fd = open(path, flags, 0666); +#endif return VFileFromFD(fd); }