Bug fix for Windows backend from Michael Beck:
It seems that Windows returns ERROR_PATH_NOT_FOUND for CreateFile()
if the path component of a file path does not exists rather than
ERROR_FILE_NOT_FOUND. Because libzip maps only the latter, generic
ZIP_ER_READ was returned before.
diff --git a/THANKS b/THANKS
index 5e1c4df..28cfe91 100644
--- a/THANKS
+++ b/THANKS
@@ -30,6 +30,7 @@
Lubomir I. Ivanov <neolit123@gmail.com>
Martin Buchholz <martinrb@google.com>
Martin Szulecki <m.szulecki@libimobiledevice.org>
+Michael Beck <mm.beck@gmx.net>
Michal Vyskocil <mvyskocil@suse.cz>
Mikhail Gusarov <dottedmag@dottedmag.net>.
Oliver Kaiser <under.northern.sky@googlemail.com>
diff --git a/lib/zip_source_win32handle.c b/lib/zip_source_win32handle.c
index 35e2e67..7fe003d 100644
--- a/lib/zip_source_win32handle.c
+++ b/lib/zip_source_win32handle.c
@@ -344,9 +344,12 @@
}
else {
h = ctx->ops->op_open(ctx);
- if (h == INVALID_HANDLE_VALUE && GetLastError() == ERROR_FILE_NOT_FOUND) {
- zip_error_set(&ctx->error, ZIP_ER_READ, ENOENT);
- return -1;
+ if (h == INVALID_HANDLE_VALUE) {
+ win32err = GetLastError();
+ if (win32err == ERROR_FILE_NOT_FOUND || win32err == ERROR_PATH_NOT_FOUND) {
+ zip_error_set(&ctx->error, ZIP_ER_READ, ENOENT);
+ return -1;
+ }
}
}