mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39:43 +01:00
Use wide-char Windows API functions on Windows
There's now a thin layer of UTF-16 around the WinAPI functions to get the path to the Documents folder and to create a new directory, so that account usernames with non-ASCII characters do not result in no VVVVVV folder being created or used.
This commit is contained in:
parent
64fd50be6f
commit
ddaa5e13c8
1 changed files with 9 additions and 2 deletions
|
@ -13,7 +13,12 @@
|
|||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#define mkdir(a, b) CreateDirectory(a, NULL)
|
||||
int mkdir(char* path, int mode)
|
||||
{
|
||||
WCHAR utf16_path[MAX_PATH];
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, utf16_path, MAX_PATH);
|
||||
return CreateDirectoryW(utf16_path, NULL);
|
||||
}
|
||||
#define VNEEDS_MIGRATION (mkdirResult != 0)
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/stat.h>
|
||||
|
@ -158,7 +163,9 @@ void PLATFORM_getOSDirectory(char* output)
|
|||
{
|
||||
#ifdef _WIN32
|
||||
/* This block is here for compatibility, do not touch it! */
|
||||
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, output);
|
||||
WCHAR utf16_path[MAX_PATH];
|
||||
SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, utf16_path);
|
||||
WideCharToMultiByte(CP_UTF8, 0, utf16_path, -1, output, MAX_PATH, NULL, NULL);
|
||||
strcat(output, "\\VVVVVV\\");
|
||||
#else
|
||||
strcpy(output, PHYSFS_getPrefDir("distractionware", "VVVVVV"));
|
||||
|
|
Loading…
Reference in a new issue