mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
do fs_is_dir smarter
This commit is contained in:
parent
b96fc7479e
commit
4bb5dbc84a
|
@ -2267,18 +2267,10 @@ int fs_removedir(const char *path)
|
||||||
int fs_is_dir(const char *path)
|
int fs_is_dir(const char *path)
|
||||||
{
|
{
|
||||||
#if defined(CONF_FAMILY_WINDOWS)
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
/* TODO: do this smarter */
|
WCHAR wPath[IO_MAX_PATH_LENGTH];
|
||||||
WIN32_FIND_DATAW finddata;
|
MultiByteToWideChar(CP_UTF8, 0, path, -1, wPath, sizeof(wPath) / sizeof(WCHAR));
|
||||||
HANDLE handle;
|
DWORD attributes = GetFileAttributesW(wPath);
|
||||||
char buffer[IO_MAX_PATH_LENGTH];
|
return attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0;
|
||||||
WCHAR wBuffer[IO_MAX_PATH_LENGTH];
|
|
||||||
str_format(buffer, sizeof(buffer), "%s/*", path);
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, buffer, -1, wBuffer, sizeof(wBuffer) / sizeof(WCHAR));
|
|
||||||
|
|
||||||
if((handle = FindFirstFileW(wBuffer, &finddata)) == INVALID_HANDLE_VALUE)
|
|
||||||
return 0;
|
|
||||||
FindClose(handle);
|
|
||||||
return 1;
|
|
||||||
#else
|
#else
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
if(stat(path, &sb) == -1)
|
if(stat(path, &sb) == -1)
|
||||||
|
|
Loading…
Reference in a new issue