cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=3b52489368837a46abf0cd4193043081256e03e8
commit 3b52489368837a46abf0cd4193043081256e03e8 Author: Nicolas Aguirre <aguirre.nico...@gmail.com> Date: Fri Jan 30 15:01:07 2015 +0100 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 --- src/lib/eina/eina_file_win32.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/lib/eina/eina_file_win32.c b/src/lib/eina/eina_file_win32.c index 4398e0b..9987fdf 100644 --- a/src/lib/eina/eina_file_win32.c +++ b/src/lib/eina/eina_file_win32.c @@ -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); --