eina: fix directory listing on windows when directory is empty.
Using of INVALID_HANDLE_VALUE and ERROR_NO_MORE_FILES to handle this properlly. @fix
This commit is contained in:
parent
797c921f10
commit
3b52489368
|
@ -144,7 +144,7 @@ _eina_file_win32_first_file(const char *dir, WIN32_FIND_DATA *fd)
|
|||
|
||||
wdir = evil_char_to_wchar(dir);
|
||||
if (!wdir)
|
||||
return NULL;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
h = FindFirstFile(wdir, fd);
|
||||
free(wdir);
|
||||
|
@ -153,14 +153,14 @@ _eina_file_win32_first_file(const char *dir, WIN32_FIND_DATA *fd)
|
|||
#endif
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
||||
while ((fd->cFileName[0] == '.') &&
|
||||
((fd->cFileName[1] == '\0') ||
|
||||
((fd->cFileName[1] == '.') && (fd->cFileName[2] == '\0'))))
|
||||
{
|
||||
if (!FindNextFile(h, fd))
|
||||
return NULL;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return h;
|
||||
|
@ -181,7 +181,11 @@ _eina_file_win32_ls_iterator_next(Eina_File_Iterator *it, void **data)
|
|||
Eina_Bool res = EINA_TRUE;
|
||||
|
||||
if (it->handle == INVALID_HANDLE_VALUE)
|
||||
return EINA_FALSE;
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_MORE_FILES)
|
||||
it->is_last = EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
is_last = it->is_last;
|
||||
#ifdef UNICODE
|
||||
|
@ -263,7 +267,11 @@ _eina_file_win32_direct_ls_iterator_next(Eina_File_Direct_Iterator *it, void **d
|
|||
Eina_Bool res = EINA_TRUE;
|
||||
|
||||
if (it->handle == INVALID_HANDLE_VALUE)
|
||||
return EINA_FALSE;
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_MORE_FILES)
|
||||
it->is_last = EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
attr = it->data.dwFileAttributes;
|
||||
is_last = it->is_last;
|
||||
|
@ -580,7 +588,7 @@ eina_file_ls(const char *dir)
|
|||
|
||||
it->handle = _eina_file_win32_first_file(new_dir, &it->data);
|
||||
free(new_dir);
|
||||
if (it->handle == INVALID_HANDLE_VALUE)
|
||||
if ((it->handle == INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_NO_MORE_FILES))
|
||||
goto free_it;
|
||||
|
||||
memcpy(it->dir, dir, length + 1);
|
||||
|
@ -631,7 +639,7 @@ eina_file_direct_ls(const char *dir)
|
|||
|
||||
it->handle = _eina_file_win32_first_file(new_dir, &it->data);
|
||||
free(new_dir);
|
||||
if (it->handle == INVALID_HANDLE_VALUE)
|
||||
if ((it->handle == INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_NO_MORE_FILES))
|
||||
goto free_it;
|
||||
|
||||
memcpy(it->dir, dir, length + 1);
|
||||
|
|
Loading…
Reference in New Issue