VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/libzip/zip_source_file_win32.c
diff options
context:
space:
mode:
authorDLL125 <134442578+DLL125@users.noreply.github.com>2023-05-25 12:52:53 +0200
committerGitHub <noreply@github.com>2023-05-25 12:52:53 +0200
commit1fc4168b81f565feab409b92ccb61c57a1c550eb (patch)
treef5b54c9699aabb120f4cfa3240164fc17fd1d075 /src/Common/libzip/zip_source_file_win32.c
parentb872702309b20f2467d58652c3b00493ac4058bd (diff)
downloadVeraCrypt-1fc4168b81f565feab409b92ccb61c57a1c550eb.tar.gz
VeraCrypt-1fc4168b81f565feab409b92ccb61c57a1c550eb.zip
Update Libzip to latest 1.9.2 (#1071)
* Libzip 1.9.2 Updated Libzip to latest version 1.9.2 and changed version number in the config.h from 1.7.3 to 1.9.2. Not sure if anything else needs to be tweaked :) * Modified Libzip to work with Visual studio * Update README.md Update libzip copyright. * Added the missing files. I've added the missing files zipconf.h and config.h, I've missed those sorry for that!
Diffstat (limited to 'src/Common/libzip/zip_source_file_win32.c')
-rw-r--r--src/Common/libzip/zip_source_file_win32.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/Common/libzip/zip_source_file_win32.c b/src/Common/libzip/zip_source_file_win32.c
index 2fe838f1..4708dc85 100644
--- a/src/Common/libzip/zip_source_file_win32.c
+++ b/src/Common/libzip/zip_source_file_win32.c
@@ -1,9 +1,9 @@
/*
zip_source_file_win32.c -- read-only Windows file source implementation
- Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
- The authors can be contacted at <libzip@nih.at>
+ The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -37,6 +37,8 @@ static bool _zip_win32_op_stat(zip_source_file_context_t *ctx, zip_source_file_s
static bool _zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HANDLE h);
+/* clang-format off */
+
static zip_source_file_operations_t ops_win32_read = {
_zip_win32_op_close,
NULL,
@@ -53,13 +55,14 @@ static zip_source_file_operations_t ops_win32_read = {
NULL
};
+/* clang-format on */
ZIP_EXTERN zip_source_t *
zip_source_win32handle(zip_t *za, HANDLE h, zip_uint64_t start, zip_int64_t len) {
if (za == NULL) {
return NULL;
}
-
+
return zip_source_win32handle_create(h, start, len, &za->error);
}
@@ -90,7 +93,7 @@ _zip_win32_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len)
zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError()));
return -1;
}
-
+
return (zip_int64_t)i;
}
@@ -112,7 +115,7 @@ _zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,
break;
default:
zip_error_set(&ctx->error, ZIP_ER_SEEK, EINVAL);
- return -1;
+ return false;
}
li.QuadPart = (LONGLONG)offset;
@@ -135,13 +138,13 @@ zip_int64_t
_zip_win32_op_tell(zip_source_file_context_t *ctx, void *f) {
LARGE_INTEGER zero;
LARGE_INTEGER new_offset;
-
+
zero.QuadPart = 0;
if (!SetFilePointerEx((HANDLE)f, zero, &new_offset, FILE_CURRENT)) {
zip_error_set(&ctx->error, ZIP_ER_SEEK, _zip_win32_error_to_errno(GetLastError()));
return -1;
}
-
+
return (zip_int64_t)new_offset.QuadPart;
}
@@ -153,6 +156,7 @@ _zip_win32_error_to_errno(DWORD win32err) {
case ERROR_INVALID_PARAMETER:
return EINVAL;
case ERROR_FILE_NOT_FOUND:
+ case ERROR_PATH_NOT_FOUND:
return ENOENT;
case ERROR_INVALID_HANDLE:
return EBADF;
@@ -180,11 +184,11 @@ _zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HAND
zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError()));
return false;
}
- if (_zip_filetime_to_time_t(mtimeft, &mtime) < 0) {
+ if (!_zip_filetime_to_time_t(mtimeft, &mtime)) {
zip_error_set(&ctx->error, ZIP_ER_READ, ERANGE);
return false;
}
-
+
st->exists = true;
st->mtime = mtime;
@@ -198,7 +202,7 @@ _zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HAND
st->size = (zip_uint64_t)size.QuadPart;
}
-
+
/* TODO: fill in ctx->attributes */
return true;