X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwin32_replacements.c;h=527d4345264484123afde97f7b8e1bbc6fc06ef9;hp=610afbdf448f78bb00c4e37359aaca85ea3ecae8;hb=91ba045392c18b7e12add95158cd2ab67c1505ae;hpb=e176e9731e696562bab8de7b9bd34c019deef3e8 diff --git a/src/win32_replacements.c b/src/win32_replacements.c index 610afbdf..527d4345 100644 --- a/src/win32_replacements.c +++ b/src/win32_replacements.c @@ -37,6 +37,7 @@ #include "wimlib/file_io.h" #include "wimlib/glob.h" #include "wimlib/error.h" +#include "wimlib/wildcard.h" #include "wimlib/util.h" /* Replacement for POSIX fsync() */ @@ -379,6 +380,7 @@ win32_wglob(const wchar_t *pattern, int flags, HANDLE hFind; int ret; size_t nspaces; + int errno_save; const wchar_t *backslash, *end_slash; size_t prefix_len; @@ -408,9 +410,7 @@ win32_wglob(const wchar_t *pattern, int flags, errno = 0; return GLOB_NOMATCH; } else { - /* The other possible error codes for FindFirstFile() - * are undocumented. */ - errno = EIO; + set_errno_from_win32_error(err); return GLOB_ABORTED; } } @@ -444,22 +444,21 @@ win32_wglob(const wchar_t *pattern, int flags, } while (FindNextFileW(hFind, &dat)); err = GetLastError(); CloseHandle(hFind); - if (err == ERROR_NO_MORE_FILES) { - errno = 0; - return 0; - } else { - /* Other possible error codes for FindNextFile() are - * undocumented */ - errno = EIO; + if (err != ERROR_NO_MORE_FILES) { + set_errno_from_win32_error(err); ret = GLOB_ABORTED; goto fail_globfree; } + return 0; + oom: CloseHandle(hFind); errno = ENOMEM; ret = GLOB_NOSPACE; fail_globfree: + errno_save = errno; globfree(pglob); + errno = errno_save; return ret; }