diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-15 18:13:26 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-15 18:13:26 +0200 |
commit | 8bff2715bfdfd2e6ce0c707f1310b169d4e454d0 (patch) | |
tree | 50c4dfdb2e4daa5b8c94697261ff8081389b449c /lib/io/src/win32 | |
parent | c9f37f069c6e294e58c64c9f5ad94f0bd3e2fd02 (diff) |
libcompat: Add a helper to get/set OS error state
On Unix like OSes, this saves/restores errno, on Windows both errno
and GetLastError state are saved/restored.
This should make it simpler to preserve that across function calls.
Additionally, while tracking down uses of GetLastError, some places
where the error code was printed out directly where replaced with
instances of w32_perror.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/src/win32')
-rw-r--r-- | lib/io/src/win32/dir_iterator.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/io/src/win32/dir_iterator.c b/lib/io/src/win32/dir_iterator.c index c99fd64..22b4870 100644 --- a/lib/io/src/win32/dir_iterator.c +++ b/lib/io/src/win32/dir_iterator.c @@ -58,11 +58,15 @@ static int dir_iterator_next(dir_iterator_t *it, dir_entry_t **out) if (w32->state == 0 && !w32->is_first) { if (!FindNextFileW(w32->dirhnd, &w32->ent)) { - if (GetLastError() == ERROR_NO_MORE_FILES) { + os_error_t err = get_os_error_state(); + + if (err.w32_errno == ERROR_NO_MORE_FILES) { w32->state = 1; } else { w32->state = SQFS_ERROR_IO; } + + set_os_error_state(err); } } |