mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fix fs_makedir and fs_storage_path with unicode on windows
This commit is contained in:
parent
9cb30a8c66
commit
3df3feb024
|
@ -2195,10 +2195,12 @@ void fs_listdir_fileinfo(const char *dir, FS_LISTDIR_CALLBACK_FILEINFO cb, int t
|
|||
int fs_storage_path(const char *appname, char *path, int max)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
char *home = getenv("APPDATA");
|
||||
WCHAR *home = _wgetenv(L"APPDATA");
|
||||
if(!home)
|
||||
return -1;
|
||||
_snprintf(path, max, "%s/%s", home, appname);
|
||||
char buffer[IO_MAX_PATH_LENGTH];
|
||||
WideCharToMultiByte(CP_UTF8, 0, home, -1, buffer, IO_MAX_PATH_LENGTH, NULL, NULL);
|
||||
_snprintf(path, max, "%s/%s", buffer, appname);
|
||||
return 0;
|
||||
#elif defined(CONF_PLATFORM_ANDROID)
|
||||
// just use the data directory
|
||||
|
@ -2249,7 +2251,9 @@ int fs_makedir_rec_for(const char *path)
|
|||
int fs_makedir(const char *path)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
if(_mkdir(path) == 0)
|
||||
WCHAR wBuffer[IO_MAX_PATH_LENGTH];
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, wBuffer, IO_MAX_PATH_LENGTH);
|
||||
if(_wmkdir(wBuffer) == 0)
|
||||
return 0;
|
||||
if(errno == EEXIST)
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue