mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #4196
4196: Fix fs_removedir and fs_remove with unicode on windows r=Jupeyy a=Robyt3 Fixes `fs_removedir` and `fs_remove` to work with unicode names on Windows. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robert.mueller@uni-siegen.de>
This commit is contained in:
commit
b2efcb8ba4
|
@ -2271,7 +2271,9 @@ int fs_makedir(const char *path)
|
|||
int fs_removedir(const char *path)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
if(_rmdir(path) == 0)
|
||||
WCHAR wPath[IO_MAX_PATH_LENGTH];
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, IO_MAX_PATH_LENGTH, wPath, IO_MAX_PATH_LENGTH);
|
||||
if(RemoveDirectoryW(wPath) != 0)
|
||||
return 0;
|
||||
return -1;
|
||||
#else
|
||||
|
@ -2357,7 +2359,9 @@ int fs_parent_dir(char *path)
|
|||
int fs_remove(const char *filename)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
return _unlink(filename) != 0;
|
||||
WCHAR wFilename[IO_MAX_PATH_LENGTH];
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename, IO_MAX_PATH_LENGTH, wFilename, IO_MAX_PATH_LENGTH);
|
||||
return DeleteFileW(wFilename) == 0;
|
||||
#else
|
||||
return unlink(filename) != 0;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue