mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fix fs_is_dir with unicode on windows
This commit is contained in:
parent
f6954c8001
commit
355466e0bf
|
@ -2257,25 +2257,22 @@ int fs_is_dir(const char *path)
|
|||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
/* TODO: do this smarter */
|
||||
WIN32_FIND_DATA finddata;
|
||||
WIN32_FIND_DATAW finddata;
|
||||
HANDLE handle;
|
||||
char buffer[1024 * 2];
|
||||
char buffer[IO_MAX_PATH_LENGTH];
|
||||
WCHAR wBuffer[IO_MAX_PATH_LENGTH];
|
||||
str_format(buffer, sizeof(buffer), "%s/*", path);
|
||||
MultiByteToWideChar(CP_UTF8, 0, buffer, IO_MAX_PATH_LENGTH, wBuffer, IO_MAX_PATH_LENGTH);
|
||||
|
||||
if((handle = FindFirstFileA(buffer, &finddata)) == INVALID_HANDLE_VALUE)
|
||||
if((handle = FindFirstFileW(wBuffer, &finddata)) == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
|
||||
FindClose(handle);
|
||||
return 1;
|
||||
#else
|
||||
struct stat sb;
|
||||
if(stat(path, &sb) == -1)
|
||||
return 0;
|
||||
|
||||
if(S_ISDIR(sb.st_mode))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
return S_ISDIR(sb.st_mode) ? 1 : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue