Made PKWARE traditional encryption optional.

Added support for disk splitting into the minizip and miniunz sample apps.
Removed change_dir function from os helpers since it is no longer needed and changing dir causes problems when trying to find the next split archive.
Cleaned up #defines and pushed more into mz.h which was previously named mz.h
Removed NOUNCRYPT and NOCRYPT and instead implemented HAVE_CRYPT which can be configured via CMake USE_CRYPT.
Fixed issues unzipping non-split archives.
Fixed return value on mz_zip_entry_write.
This commit is contained in:
Nathan Moinvaziri 2017-10-16 07:37:11 -07:00
parent 99fe057281
commit 00cca9f511
26 changed files with 299 additions and 323 deletions

View File

@ -5,9 +5,10 @@
#***************************************************************************
cmake_minimum_required(VERSION 2.8)
option(USE_AES "Enables building of AES library" ON)
option(USE_BZIP2 "Enables building of BZIP2 library" ON)
option(USE_LZMA "Enables building of LZMA library" ON)
option(USE_CRYPT "Enables building with PKWARE traditional encryption" ON)
option(USE_AES "Enables building with AES library" ON)
option(USE_BZIP2 "Enables building with BZIP2 library" ON)
option(USE_LZMA "Enables building with LZMA library" ON)
option(BUILD_TEST "Enables building of executables minizip and miniunz. Requires ZLIB!" OFF)
# Set a consistent MACOSX_RPATH default across all CMake versions.
@ -46,7 +47,6 @@ set(MINIZIP_SRC
mz_os.c
mz_strm.c
mz_strm_buf.c
mz_strm_crypt.c
mz_strm_mem.c
mz_strm_posix.c
mz_strm_split.c
@ -55,11 +55,10 @@ set(MINIZIP_SRC
mz_zip.c)
set(MINIZIP_PUBLIC_HEADERS
mz_error.h
mz.h
mz_os.h
mz_strm.h
mz_strm_buf.h
mz_strm_crypt.h
mz_strm_mem.h
mz_strm_posix.h
mz_strm_split.h
@ -93,6 +92,13 @@ if(UNIX)
link_directories(${LIBBSD_LIBRARY_DIRS})
endif()
if(USE_CRYPT)
add_definitions(-DHAVE_CRYPT)
list(APPEND MINIZIP_SRC "mz_strm_crypt.c")
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_crypt.h")
endif()
if(USE_AES)
add_definitions(-DHAVE_AES)

View File

@ -22,9 +22,10 @@
#include <time.h>
#include <errno.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_os.h"
#include "mz_strm.h"
#include "mz_strm_split.h"
#include "mz_unzip.h"
/***************************************************************************/
@ -40,11 +41,11 @@ void miniunz_help()
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
" -e Extract without path (junk paths)\n" \
" -x Extract with path\n" \
" -v list files\n" \
" -l list files\n" \
" -d directory to extract into\n" \
" -o overwrite files without prompting\n" \
" -p extract crypted file using password\n\n");
" -v List files\n" \
" -l List files\n" \
" -d Directory to extract into\n" \
" -o Overwrite files without prompting\n" \
" -p Extract crypted file using password\n\n");
}
/***************************************************************************/
@ -84,7 +85,7 @@ int32_t miniunz_list(void *handle)
ratio = (uint32_t)((file_info->compressed_size * 100) / file_info->uncompressed_size);
// Display a '*' if the file is encrypted
if ((file_info->flag & 1) != 0)
if (file_info->flag & MZ_ZIP_FLAG_ENCRYPTED)
crypt = '*';
switch (file_info->compression_method)
@ -138,7 +139,7 @@ int32_t miniunz_list(void *handle)
int32_t miniunz_extract_currentfile(void *handle, uint8_t opt_extract_without_path, uint8_t *opt_overwrite, const char *password)
{
mz_unzip_file *file_info = NULL;
uint8_t buf[UINT16_MAX];
uint8_t buf[INT16_MAX];
int32_t read = 0;
int32_t written = 0;
int16_t err = MZ_OK;
@ -328,6 +329,8 @@ int main(int argc, const char *argv[])
{
void *handle = NULL;
void *stream = NULL;
void *split_stream = NULL;
void *open_stream = NULL;
int16_t i = 0;
uint8_t opt_do_list = 0;
uint8_t opt_do_extract = 1;
@ -353,7 +356,7 @@ int main(int argc, const char *argv[])
{
if ((*argv[i]) == '-')
{
const char *p = argv[i]+1;
const char *p = argv[i] + 1;
while (*p != 0)
{
@ -371,12 +374,12 @@ int main(int argc, const char *argv[])
if ((c == 'd') || (c == 'D'))
{
opt_extractdir = 1;
directory = argv[i+1];
directory = argv[i + 1];
}
if (((c == 'p') || (c == 'P')) && (i+1 < argc))
if (((c == 'p') || (c == 'P')) && (i + 1 < argc))
{
password = argv[i+1];
password = argv[i + 1];
i += 1;
}
}
@ -398,54 +401,55 @@ int main(int argc, const char *argv[])
mz_stream_os_create(&stream);
if (mz_stream_open(stream, path, MZ_STREAM_MODE_READ) != MZ_OK)
mz_stream_split_create(&split_stream);
mz_stream_set_base(split_stream, stream);
err = mz_stream_open(split_stream, path, MZ_STREAM_MODE_READ);
if (err != MZ_OK)
{
mz_stream_os_delete(&stream);
printf("Error opening file %s\n", path);
return 1;
}
// Open zip file
handle = mz_unzip_open(stream);
if (handle == NULL)
else
{
mz_stream_os_close(stream);
mz_stream_os_delete(&stream);
printf("Error opening zip %s\n", path);
return 1;
}
// Open zip file
handle = mz_unzip_open(split_stream);
printf("%s opened\n", path);
// Process command line options
if (opt_do_list)
{
err = miniunz_list(handle);
}
else if (opt_do_extract)
{
if (directory != NULL)
if (handle == NULL)
{
// Create target directory if it doesn't exist
mz_make_dir(directory);
printf("Error opening zip %s\n", path);
err = 1;
}
else
{
printf("%s opened\n", path);
if ((opt_extractdir) && (mz_os_change_dir(directory) != MZ_OK))
// Process command line options
if (opt_do_list)
{
printf("Error changing into %s, aborting\n", directory);
exit(-1);
err = miniunz_list(handle);
}
else if (opt_do_extract)
{
if (directory != NULL)
{
// Create target directory if it doesn't exist
mz_make_dir(directory);
}
if (filename_to_extract == NULL)
err = miniunz_extract_all(handle, opt_do_extract_withoutpath, opt_overwrite, password);
else
err = miniunz_extract_onefile(handle, filename_to_extract, opt_do_extract_withoutpath, opt_overwrite, password);
}
mz_unzip_close(handle);
}
if (filename_to_extract == NULL)
err = miniunz_extract_all(handle, opt_do_extract_withoutpath, opt_overwrite, password);
else
err = miniunz_extract_onefile(handle, filename_to_extract, opt_do_extract_withoutpath, opt_overwrite, password);
mz_stream_os_close(stream);
}
mz_unzip_close(handle);
mz_stream_os_close(stream);
mz_stream_split_delete(&split_stream);
mz_stream_os_delete(&stream);
return err;

View File

@ -22,9 +22,10 @@
#include <time.h>
#include <errno.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_os.h"
#include "mz_strm.h"
#include "mz_strm_split.h"
#include "mz_zip.h"
/***************************************************************************/
@ -37,7 +38,7 @@ void minizip_banner()
void minizip_help()
{
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n");
printf("Usage : minizip [-o] [-a] [-0 to -9] [-b|-m] [-s] [-j] [-p password] [-k 512] file.zip [files_to_add]\n\n");
printf(" -o Overwrite existing file.zip\n");
printf(" -a Append to existing file.zip\n");
printf(" -0 Store only\n");
@ -52,6 +53,8 @@ void minizip_help()
#ifdef HAVE_AES
printf(" -s AES encryption\n");
#endif
printf(" -p Encryption password\n");
printf(" -k Disk size in KB\n");
printf(" -j Exclude path and store only the file name\n\n");
}
@ -65,7 +68,7 @@ int32_t minizip_add_file(void *handle, const char *path, uint8_t opt_exclude_pat
int16_t err_close = MZ_OK;
void *stream = NULL;
const char *filenameinzip = NULL;
char buf[UINT16_MAX];
char buf[INT16_MAX];
// Construct the filename that our file will be stored in the zip as.
@ -198,10 +201,13 @@ int32_t minizip_add(void *handle, const char *path, uint8_t opt_exclude_path, mz
int main(int argc, char *argv[])
{
void *handle = NULL;
void *stream = NULL;
void *file_stream = NULL;
void *split_stream = NULL;
void *open_stream = NULL;
char *path = NULL;
mz_zip_compress compress_info;
mz_zip_crypt crypt_info;
int64_t disk_size = 0;
int32_t path_arg = 0;
uint8_t opt_append = 0;
uint8_t opt_open_existing = 0;
@ -258,6 +264,11 @@ int main(int argc, char *argv[])
if ((c == 's') || (c == 'S'))
crypt_info.aes = 1;
#endif
if (((c == 'k') || (c == 'k')) && (i + 1 < argc))
{
disk_size = atoi(argv[i + 1]) * 1024;
i += 1;
}
if (((c == 'p') || (c == 'P')) && (i + 1 < argc))
{
crypt_info.password = argv[i + 1];
@ -317,7 +328,7 @@ int main(int argc, char *argv[])
}
}
mz_stream_os_create(&stream);
mz_stream_os_create(&file_stream);
mode = MZ_STREAM_MODE_READWRITE;
if (opt_append)
@ -325,44 +336,55 @@ int main(int argc, char *argv[])
else
mode |= MZ_STREAM_MODE_CREATE;
if (mz_stream_open(stream, path, mode) != MZ_OK)
if (disk_size > 0)
{
mz_stream_os_delete(&stream);
printf("Error opening file %s\n", path);
return 1;
mz_stream_split_create(&split_stream);
mz_stream_set_base(split_stream, file_stream);
mz_stream_split_set_prop_int64(split_stream, MZ_STREAM_PROP_DISK_SIZE, disk_size);
open_stream = split_stream;
}
else
{
open_stream = file_stream;
}
handle = mz_zip_open(opt_open_existing, stream);
err = mz_stream_open(open_stream, path, mode);
if (handle == NULL)
if (err != MZ_OK)
{
mz_stream_os_delete(&stream);
printf("Error opening zip %s\n", path);
return 1;
printf("Error opening file %s\n", path);
}
else
{
handle = mz_zip_open(opt_open_existing, open_stream);
if (handle == NULL)
{
printf("Error opening zip %s\n", path);
err = MZ_FORMAT_ERROR;
}
else
{
printf("Creating %s\n", path);
// Go through command line args looking for files to add to zip
for (i = path_arg + 1; (i < argc) && (err == MZ_OK); i += 1)
err = minizip_add(handle, argv[i], opt_exclude_path, &compress_info, &crypt_info, 1);
err_close = mz_zip_close(handle, NULL, MZ_VERSION_MADEBY);
if (err_close != MZ_OK)
printf("Error in closing %s (%d)\n", path, err_close);
}
mz_stream_os_close(file_stream);
}
printf("Creating %s\n", path);
if (split_stream != NULL)
mz_stream_split_delete(&split_stream);
// Go through command line args looking for files to add to zip
for (i = path_arg + 1; (i < argc) && (err == MZ_OK); i++)
{
const char *filename = argv[i];
// Skip command line options
if ((((*(argv[i])) == '-') || ((*(argv[i])) == '/')) && (strlen(argv[i]) == 2) &&
((argv[i][1] == 'o') || (argv[i][1] == 'O') || (argv[i][1] == 'a') || (argv[i][1] == 'A') ||
(argv[i][1] == 'p') || (argv[i][1] == 'P') || ((argv[i][1] >= '0') && (argv[i][1] <= '9'))))
continue;
err = minizip_add(handle, filename, opt_exclude_path, &compress_info, &crypt_info, 1);
}
err_close = mz_zip_close(handle, NULL, MZ_VERSION_MADEBY);
if (err_close != MZ_OK)
printf("Error in closing %s (%d)\n", path, err_close);
mz_stream_os_close(stream);
mz_stream_os_delete(&stream);
mz_stream_os_delete(&file_stream);
return err;
}

74
mz.h Normal file
View File

@ -0,0 +1,74 @@
/* mz.h -- Errors codes, zip flags and magic
Version 2.0.0, October 4th, 2017
part of the MiniZip project
Copyright (C) 2012-2017 Nathan Moinvaziri
https://github.com/nmoinvaz/minizip
Copyright (C) 1998-2010 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _MZ_H
#define _MZ_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
// MZ_ERROR
#define MZ_OK (0)
#define MZ_EOF (MZ_OK)
#define MZ_STREAM_ERROR (-1)
#define MZ_DATA_ERROR (-3)
#define MZ_MEM_ERROR (-4)
#define MZ_END_OF_LIST (-100)
#define MZ_PARAM_ERROR (-102)
#define MZ_FORMAT_ERROR (-103)
#define MZ_INTERNAL_ERROR (-104)
#define MZ_CRC_ERROR (-105)
#define MZ_CRYPT_ERROR (-106)
#define MZ_EXIST_ERROR (-107)
// MZ_COMPRESS_METHOD
#define MZ_COMPRESS_METHOD_RAW (0)
#define MZ_COMPRESS_METHOD_DEFLATE (8)
#define MZ_COMPRESS_METHOD_BZIP2 (12)
#define MZ_COMPRESS_METHOD_LZMA (14)
// MZ_COMPRESS_OPTIONS
#define MZ_COMPRESS_LEVEL_DEFAULT (-1)
#define MZ_COMPRESS_WINDOW_BITS_DEFAULT (0)
#define MZ_COMPRESS_MEM_LEVEL_DEFAULT (0)
#define MZ_COMPRESS_STRATEGY_DEFAULT (-1)
// MZ_ZIP_FLAG
#define MZ_ZIP_FLAG_ENCRYPTED (1 << 0)
#define MZ_ZIP_FLAG_LZMA_EOS_MARKER (1 << 1)
#define MZ_ZIP_FLAG_DEFLATE_MAX (1 << 1)
#define MZ_ZIP_FLAG_DEFLATE_NORMAL (0)
#define MZ_ZIP_FLAG_DEFLATE_FAST (1 << 2)
#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | \
MZ_ZIP_FLAG_DEFLATE_MAX)
#define MZ_ZIP_FLAG_DATA_DESCRIPTOR (1 << 3)
// MZ_ZIP_MAGIC
#define MZ_ZIP_MAGIC_DISKHEADER (0x08074b50)
#define MZ_ZIP_MAGIC_LOCALHEADER (0x04034b50)
#define MZ_ZIP_MAGIC_CENTRALHEADER (0x02014b50)
#define MZ_ZIP_MAGIC_ENDHEADER (0x06054b50)
#define MZ_ZIP_MAGIC_ENDHEADER64 (0x06064b50)
#define MZ_ZIP_MAGIC_ENDLOCHEADER64 (0x07064b50)
#define MZ_ZIP_MAGIC_DATADESCRIPTOR (0x08074b50)
/***************************************************************************/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,42 +0,0 @@
/* mz_error.h -- List of function return codes
Version 2.0.0, October 4th, 2017
part of the MiniZip project
Copyright (C) 2012-2017 Nathan Moinvaziri
https://github.com/nmoinvaz/minizip
Copyright (C) 1998-2010 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef _MZ_ERROR_H
#define _MZ_ERROR_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
#define MZ_OK (0)
#define MZ_EOF (MZ_OK)
#define MZ_STREAM_ERROR (-1)
#define MZ_DATA_ERROR (-3)
#define MZ_MEM_ERROR (-4)
#define MZ_END_OF_LIST (-100)
#define MZ_PARAM_ERROR (-102)
#define MZ_FORMAT_ERROR (-103)
#define MZ_INTERNAL_ERROR (-104)
#define MZ_CRC_ERROR (-105)
#define MZ_CRYPT_ERROR (-106)
#define MZ_EXIST_ERROR (-107)
/***************************************************************************/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -15,7 +15,7 @@
#include <time.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_os.h"

View File

@ -81,13 +81,6 @@ int16_t mz_posix_set_file_date(const char *path, uint32_t dos_date)
return MZ_OK;
}
int16_t mz_posix_change_dir(const char *path)
{
if (chdir(path) != 0)
return MZ_INTERNAL_ERROR;
return MZ_OK;
}
int16_t mz_posix_make_dir(const char *path)
{
int16_t err = 0;

View File

@ -32,7 +32,6 @@ extern "C" {
int32_t mz_posix_rand(uint8_t *buf, int32_t size);
int16_t mz_posix_get_file_date(const char *path, uint32_t *dos_date);
int16_t mz_posix_set_file_date(const char *path, uint32_t dos_date);
int16_t mz_posix_change_dir(const char *path);
int16_t mz_posix_make_dir(const char *path);
DIR* mz_posix_open_dir(const char *path);
struct
@ -45,7 +44,6 @@ int32_t mz_posix_is_dir(const char *path);
#define mz_os_rand mz_posix_rand
#define mz_os_get_file_date mz_posix_get_file_date
#define mz_os_set_file_date mz_posix_set_file_date
#define mz_os_change_dir mz_posix_change_dir
#define mz_os_make_dir mz_posix_make_dir
#define mz_os_open_dir mz_posix_open_dir
#define mz_os_read_dir mz_posix_read_dir

View File

@ -18,7 +18,7 @@
#include <windows.h>
#include <wincrypt.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_os_win32.h"
@ -117,26 +117,6 @@ int16_t mz_win32_set_file_date(const char *path, uint32_t dos_date)
return err;
}
int16_t mz_win32_change_dir(const char *path)
{
wchar_t *path_wide = NULL;
uint32_t path_wide_size = 0;
int16_t err = MZ_OK;
path_wide_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
path_wide = (wchar_t *)malloc((path_wide_size + 1) * sizeof(wchar_t));
memset(path_wide, 0, sizeof(wchar_t) * (path_wide_size + 1));
MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wide, path_wide_size);
if (_wchdir(path_wide) != 0)
err = MZ_INTERNAL_ERROR;
free(path_wide);
return err;
}
int16_t mz_win32_make_dir(const char *path)
{
wchar_t *path_wide = NULL;

View File

@ -34,7 +34,6 @@ typedef void* DIR;
int32_t mz_win32_rand(uint8_t *buf, int32_t size);
int16_t mz_win32_get_file_date(const char *path, uint32_t *dos_date);
int16_t mz_win32_set_file_date(const char *path, uint32_t dos_date);
int16_t mz_win32_change_dir(const char *path);
int16_t mz_win32_make_dir(const char *path);
DIR* mz_win32_open_dir(const char *path);
struct
@ -47,7 +46,6 @@ int32_t mz_win32_is_dir(const char *path);
#define mz_os_rand mz_win32_rand
#define mz_os_get_file_date mz_win32_get_file_date
#define mz_os_set_file_date mz_win32_set_file_date
#define mz_os_change_dir mz_win32_change_dir
#define mz_os_make_dir mz_win32_make_dir
#define mz_os_open_dir mz_win32_open_dir
#define mz_os_read_dir mz_win32_read_dir

View File

@ -15,7 +15,7 @@
#include <time.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
/***************************************************************************/

View File

@ -17,7 +17,7 @@
#include "aes.h"
#include "fileenc.h"
#include "mz_error.h"
#include "mz.h"
#include "mz_os.h"
#include "mz_strm.h"
#include "mz_strm_aes.h"

View File

@ -17,7 +17,7 @@
#include <string.h>
#include <stdarg.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_buf.h"

View File

@ -17,7 +17,7 @@
#include "bzlib.h"
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_bzip.h"

View File

@ -20,9 +20,6 @@
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT.
*/
@ -32,7 +29,7 @@
#include "zlib.h"
#include "mz_error.h"
#include "mz.h"
#include "mz_os.h"
#include "mz_strm.h"
#include "mz_strm_crypt.h"

View File

@ -18,7 +18,7 @@
#include <lzma.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_lzma.h"

View File

@ -13,8 +13,8 @@
Copyright (C) 1998-2003 Gilles Vollant
http://www.winimage.com/zLibDll/minizip.html
This file is under the same license as the Unzip tool it is distributed
with.
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_mem.h"

View File

@ -19,7 +19,7 @@
#include <string.h>
#include <errno.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_posix.h"

View File

@ -5,8 +5,8 @@
Copyright (C) 2012-2017 Nathan Moinvaziri
https://github.com/nmoinvaz/minizip
This file is under the same license as the Unzip tool it is distributed
with.
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
@ -14,7 +14,7 @@
#include <stdlib.h>
#include <string.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_split.h"
@ -57,10 +57,6 @@ typedef struct mz_stream_split_s {
/***************************************************************************/
#define DISKHEADERMAGIC (0x08074b50)
/***************************************************************************/
int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
{
mz_stream_split *split = (mz_stream_split *)stream;
@ -95,7 +91,7 @@ int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
{
if (split->current_disk == 0)
{
err = mz_stream_write_uint32(split->stream.base, DISKHEADERMAGIC);
err = mz_stream_write_uint32(split->stream.base, MZ_ZIP_MAGIC_DISKHEADER);
split->total_out_disk += 4;
split->total_out += split->total_out_disk;
}
@ -105,7 +101,7 @@ int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
if (split->current_disk == 0)
{
err = mz_stream_read_uint32(split->stream.base, &magic);
if (magic != DISKHEADERMAGIC)
if (magic != MZ_ZIP_MAGIC_DISKHEADER)
err = MZ_FORMAT_ERROR;
}
}

View File

@ -18,7 +18,7 @@
#include <windows.h>
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_win32.h"

View File

@ -60,7 +60,6 @@ void* mz_stream_win32_get_interface(void);
#define mz_os_rand mz_win32_rand
#define mz_os_get_file_date mz_win32_get_file_date
#define mz_os_set_file_date mz_win32_set_file_date
#define mz_os_change_dir mz_win32_change_dir
#define mz_os_make_dir mz_win32_make_dir
#define mz_os_open_dir mz_win32_open_dir
#define mz_os_read_dir mz_win32_read_dir

View File

@ -17,7 +17,7 @@
#include "zlib.h"
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_zlib.h"

View File

@ -25,19 +25,19 @@
#include "zlib.h"
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#ifdef HAVE_AES
#include "mz_strm_aes.h"
# include "mz_strm_aes.h"
#endif
#ifdef HAVE_BZIP2
#include "mz_strm_bzip.h"
# include "mz_strm_bzip.h"
#endif
#ifndef NOUNCRYPT
#ifdef HAVE_CRYPT
# include "mz_strm_crypt.h"
#endif
#ifdef HAVE_LZMA
#include "mz_strm_lzma.h"
# include "mz_strm_lzma.h"
#endif
#include "mz_strm_mem.h"
#include "mz_strm_zlib.h"
@ -46,19 +46,12 @@
/***************************************************************************/
#define DISKHEADERMAGIC (0x08074b50)
#define LOCALHEADERMAGIC (0x04034b50)
#define CENTRALHEADERMAGIC (0x02014b50)
#define ENDHEADERMAGIC (0x06054b50)
#define ZIP64ENDHEADERMAGIC (0x06064b50)
#define ZIP64ENDLOCHEADERMAGIC (0x07064b50)
#define SIZECENTRALDIRITEM (0x2e)
#define SIZECENTRALHEADERLOCATOR (0x14)
#define SIZEZIPLOCALHEADER (0x1e)
#define MZ_ZIP_SIZE_CD_ITEM (0x2e)
#define MZ_ZIP_SIZE_CD_LOCATOR64 (0x14)
#define MZ_ZIP_SIZE_LOCALHEADER (0x1e)
#ifndef BUFREADCOMMENT
# define BUFREADCOMMENT (0x400)
# define BUFREADCOMMENT (0x400)
#endif
/***************************************************************************/
@ -141,10 +134,10 @@ static int32_t mz_unzip_search_cd(void *stream, uint64_t *central_pos)
for (i = read_size - 3; (i--) > 0;)
{
if (((*(buf + i)) == (ENDHEADERMAGIC & 0xff)) &&
((*(buf + i + 1)) == (ENDHEADERMAGIC >> 8 & 0xff)) &&
((*(buf + i + 2)) == (ENDHEADERMAGIC >> 16 & 0xff)) &&
((*(buf + i + 3)) == (ENDHEADERMAGIC >> 24 & 0xff)))
if (((*(buf + i)) == (MZ_ZIP_MAGIC_ENDHEADER & 0xff)) &&
((*(buf + i + 1)) == (MZ_ZIP_MAGIC_ENDHEADER >> 8 & 0xff)) &&
((*(buf + i + 2)) == (MZ_ZIP_MAGIC_ENDHEADER >> 16 & 0xff)) &&
((*(buf + i + 3)) == (MZ_ZIP_MAGIC_ENDHEADER >> 24 & 0xff)))
{
*central_pos = read_pos + i;
return MZ_OK;
@ -169,12 +162,12 @@ static int32_t mz_unzip_search_zip64_cd(void *stream, const uint64_t end_central
*central_pos = 0;
// Zip64 end of central directory locator
err = mz_stream_seek(stream, end_central_offset - SIZECENTRALHEADERLOCATOR, MZ_STREAM_SEEK_SET);
err = mz_stream_seek(stream, end_central_offset - MZ_ZIP_SIZE_CD_LOCATOR64, MZ_STREAM_SEEK_SET);
// Read locator signature
if (err == MZ_OK)
{
err = mz_stream_read_uint32(stream, &value32);
if (value32 != ZIP64ENDLOCHEADERMAGIC)
if (value32 != MZ_ZIP_MAGIC_ENDLOCHEADER64)
err = MZ_FORMAT_ERROR;
}
// Number of the disk with the start of the zip64 end of central directory
@ -193,7 +186,7 @@ static int32_t mz_unzip_search_zip64_cd(void *stream, const uint64_t end_central
if (err == MZ_OK)
{
err = mz_stream_read_uint32(stream, &value32);
if (value32 != ZIP64ENDHEADERMAGIC)
if (value32 != MZ_ZIP_MAGIC_ENDHEADER64)
err = MZ_FORMAT_ERROR;
}
@ -323,10 +316,6 @@ extern void* ZEXPORT mz_unzip_open(void *stream)
if (err == MZ_OK)
{
// Hack for zip files that have no respect for zip64
//if ((central_pos > 0xffffffff) && (unzip->offset_central_dir < 0xffffffff))
// unzip->offset_central_dir = central_pos - unzip->size_central_dir;
unzip->byte_before_the_zipfile = central_pos - (unzip->offset_central_dir + unzip->size_central_dir);
unzip->central_pos = central_pos;
}
@ -444,9 +433,9 @@ static int mz_unzip_entry_read_header(void *handle)
{
if (mz_stream_read_uint32(unzip->stream, &magic) != MZ_OK)
err = MZ_STREAM_ERROR;
else if (magic == ENDHEADERMAGIC || magic == ZIP64ENDHEADERMAGIC)
else if (magic == MZ_ZIP_MAGIC_ENDHEADER || magic == MZ_ZIP_MAGIC_ENDHEADER64)
err = MZ_END_OF_LIST;
else if (magic != CENTRALHEADERMAGIC)
else if (magic != MZ_ZIP_MAGIC_CENTRALHEADER)
err = MZ_FORMAT_ERROR;
}
@ -646,7 +635,7 @@ static int mz_unzip_entry_check_header(mz_unzip *unzip, uint32_t *extrainfo_size
{
if (mz_stream_read_uint32(unzip->stream, &magic) != MZ_OK)
err = MZ_STREAM_ERROR;
else if (magic != LOCALHEADERMAGIC)
else if (magic != MZ_ZIP_MAGIC_LOCALHEADER)
err = MZ_FORMAT_ERROR;
}
@ -690,7 +679,7 @@ static int mz_unzip_entry_check_header(mz_unzip *unzip, uint32_t *extrainfo_size
if (mz_stream_read_uint16(unzip->stream, &extrafield_size) != MZ_OK)
err = MZ_STREAM_ERROR;
*extrafield_local_offset = unzip->file_info.disk_offset + SIZEZIPLOCALHEADER + filename_size;
*extrafield_local_offset = unzip->file_info.disk_offset + MZ_ZIP_SIZE_LOCALHEADER + filename_size;
*extrafield_local_size = extrafield_size;
*extrainfo_size += extrafield_size;
@ -708,7 +697,7 @@ extern int ZEXPORT mz_unzip_entry_open(void *handle, int raw, const char *passwo
int64_t footer_size = 0;
int16_t err = MZ_OK;
#ifdef NOUNCRYPT
#if !defined(HAVE_CRYPT) && !defined(HAVE_AES)
if (password != NULL)
return MZ_PARAM_ERROR;
#endif
@ -719,10 +708,13 @@ extern int ZEXPORT mz_unzip_entry_open(void *handle, int raw, const char *passwo
if (unzip->entry_header_read == 0)
return MZ_PARAM_ERROR;
if ((unzip->file_info.flag & 1) && (password == NULL))
if ((unzip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) && (password == NULL))
return MZ_PARAM_ERROR;
mz_stream_set_prop_int64(unzip->stream, MZ_STREAM_PROP_DISK_NUMBER, unzip->file_info.disk_num_start);
if (unzip->file_info.disk_num_start == unzip->global_info.number_disk_with_CD)
mz_stream_set_prop_int64(unzip->stream, MZ_STREAM_PROP_DISK_NUMBER, -1);
else
mz_stream_set_prop_int64(unzip->stream, MZ_STREAM_PROP_DISK_NUMBER, unzip->file_info.disk_num_start);
err = mz_unzip_entry_check_header(unzip, &size_variable, &extrafield_local_offset, &extrafield_local_size);
if (err != MZ_OK)
@ -753,7 +745,7 @@ extern int ZEXPORT mz_unzip_entry_open(void *handle, int raw, const char *passwo
unzip->byte_before_the_zipfile = unzip->byte_before_the_zipfile;
unzip->pos_in_zipfile = unzip->file_info.disk_offset +
SIZEZIPLOCALHEADER + size_variable;
MZ_ZIP_SIZE_LOCALHEADER + size_variable;
if (err == MZ_OK)
{
@ -764,8 +756,7 @@ extern int ZEXPORT mz_unzip_entry_open(void *handle, int raw, const char *passwo
max_total_in = unzip->file_info.compressed_size;
#ifndef NOUNCRYPT
if (unzip->file_info.flag & 1)
if (unzip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED)
{
#ifdef HAVE_AES
if (unzip->aes_version > 0)
@ -776,33 +767,35 @@ extern int ZEXPORT mz_unzip_entry_open(void *handle, int raw, const char *passwo
if (mz_stream_get_prop_int64(unzip->crypt_stream, MZ_STREAM_PROP_FOOTER_SIZE, &footer_size) == MZ_OK)
max_total_in -= footer_size;
mz_stream_set_base(unzip->crypt_stream, unzip->stream);
if (mz_stream_open(unzip->crypt_stream, NULL, MZ_STREAM_MODE_READ) != MZ_OK)
err = MZ_INTERNAL_ERROR;
}
else
#endif
{
#ifdef HAVE_CRYPT
mz_stream_crypt_create(&unzip->crypt_stream);
mz_stream_crypt_set_password(unzip->crypt_stream, password);
#endif
}
}
if (err == MZ_OK)
{
if (unzip->crypt_stream == NULL)
{
mz_stream_passthru_create(&unzip->crypt_stream);
mz_stream_set_base(unzip->crypt_stream, unzip->stream);
}
else
{
mz_stream_set_base(unzip->crypt_stream, unzip->stream);
if (mz_stream_open(unzip->crypt_stream, NULL, MZ_STREAM_MODE_READ) != MZ_OK)
err = MZ_STREAM_ERROR;
}
#endif
}
if (unzip->crypt_stream == NULL)
{
mz_stream_passthru_create(&unzip->crypt_stream);
mz_stream_set_base(unzip->crypt_stream, unzip->stream);
}
if (mz_stream_get_prop_int64(unzip->crypt_stream, MZ_STREAM_PROP_TOTAL_IN, &total_in) == MZ_OK)
max_total_in -= total_in;
if (mz_stream_get_prop_int64(unzip->crypt_stream, MZ_STREAM_PROP_TOTAL_IN, &total_in) == MZ_OK)
max_total_in -= total_in;
}
if (err == MZ_OK)
{
@ -828,7 +821,7 @@ extern int ZEXPORT mz_unzip_entry_open(void *handle, int raw, const char *passwo
if (err == MZ_OK)
{
if (unzip->file_info.flag & 1)
if (unzip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED)
mz_stream_set_prop_int64(unzip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, max_total_in);
mz_stream_set_base(unzip->compress_stream, unzip->crypt_stream);
@ -1012,7 +1005,7 @@ extern int ZEXPORT mz_unzip_goto_next_entry(void *handle)
if (unzip->entry_header_read == 0)
return MZ_END_OF_LIST;
unzip->pos_in_central_dir += SIZECENTRALDIRITEM + unzip->file_info.filename_size +
unzip->pos_in_central_dir += MZ_ZIP_SIZE_CD_ITEM + unzip->file_info.filename_size +
unzip->file_info.extrafield_size + unzip->file_info.comment_size;
return mz_unzip_entry_read_header(handle);

View File

@ -31,15 +31,6 @@ extern "C" {
/***************************************************************************/
#ifndef MZ_COMPRESS_METHOD
# define MZ_COMPRESS_METHOD_RAW (0)
# define MZ_COMPRESS_METHOD_DEFLATE (8)
# define MZ_COMPRESS_METHOD_BZIP2 (12)
# define MZ_COMPRESS_METHOD_LZMA (14)
#endif
/***************************************************************************/
// Global data about the zip file that come from the end of central dir
typedef struct mz_unzip_global_s
{

View File

@ -23,7 +23,7 @@
#include "zlib.h"
#include "mz_error.h"
#include "mz.h"
#include "mz_strm.h"
#ifdef HAVE_AES
# include "mz_strm_aes.h"
@ -31,7 +31,7 @@
#ifdef HAVE_BZIP2
# include "mz_strm_bzip.h"
#endif
#ifndef NOCRYPT
#ifdef HAVE_CRYPT
# include "mz_strm_crypt.h"
#endif
#ifdef HAVE_LZMA
@ -44,35 +44,16 @@
/***************************************************************************/
#define DISKHEADERMAGIC (0x08074b50)
#define LOCALHEADERMAGIC (0x04034b50)
#define CENTRALHEADERMAGIC (0x02014b50)
#define ENDHEADERMAGIC (0x06054b50)
#define ZIP64ENDHEADERMAGIC (0x06064b50)
#define ZIP64ENDLOCHEADERMAGIC (0x07064b50)
#define DATADESCRIPTORMAGIC (0x08074b50)
#define SIZECENTRALHEADER (0x2e) // 46
#define SIZECENTRALHEADERLOCATOR (0x14) // 20
#define SIZECENTRALDIRITEM (0x2e)
#define SIZEZIPLOCALHEADER (0x1e)
#define MZ_ZIP_SIZE_CD_ITEM (0x2e)
#define MZ_ZIP_SIZE_CD_LOCATOR64 (0x14)
#define MZ_ZIP_SIZE_LOCALHEADER (0x1e)
#ifndef BUFREADCOMMENT
# define BUFREADCOMMENT (0x400)
# define BUFREADCOMMENT (0x400)
#endif
/***************************************************************************/
#define MZ_ZIP_FLAG_ENCRYPTED (1 << 0)
#define MZ_ZIP_FLAG_LZMA_EOS_MARKER (1 << 1)
#define MZ_ZIP_FLAG_DEFLATE_MAX (1 << 1)
#define MZ_ZIP_FLAG_DEFLATE_NORMAL (0)
#define MZ_ZIP_FLAG_DEFLATE_FAST (1 << 2)
#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | MZ_ZIP_FLAG_DEFLATE_MAX)
#define MZ_ZIP_FLAG_DATA_DESCRIPTOR (1 << 3)
/***************************************************************************/
typedef struct mz_zip_s
{
mz_zip_file file_info;
@ -138,10 +119,10 @@ static int32_t mz_zip_search_cd(void *stream, uint64_t *central_pos)
for (i = read_size - 3; (i--) > 0;)
{
if (((*(buf + i)) == (ENDHEADERMAGIC & 0xff)) &&
((*(buf + i + 1)) == (ENDHEADERMAGIC >> 8 & 0xff)) &&
((*(buf + i + 2)) == (ENDHEADERMAGIC >> 16 & 0xff)) &&
((*(buf + i + 3)) == (ENDHEADERMAGIC >> 24 & 0xff)))
if (((*(buf + i)) == (MZ_ZIP_MAGIC_ENDHEADER & 0xff)) &&
((*(buf + i + 1)) == (MZ_ZIP_MAGIC_ENDHEADER >> 8 & 0xff)) &&
((*(buf + i + 2)) == (MZ_ZIP_MAGIC_ENDHEADER >> 16 & 0xff)) &&
((*(buf + i + 3)) == (MZ_ZIP_MAGIC_ENDHEADER >> 24 & 0xff)))
{
*central_pos = read_pos + i;
return MZ_OK;
@ -166,12 +147,12 @@ static int32_t mz_zip_search_zip64_cd(void *stream, const uint64_t end_central_o
*central_pos = 0;
// Zip64 end of central directory locator
err = mz_stream_seek(stream, end_central_offset - SIZECENTRALHEADERLOCATOR, MZ_STREAM_SEEK_SET);
err = mz_stream_seek(stream, end_central_offset - MZ_ZIP_SIZE_CD_LOCATOR64, MZ_STREAM_SEEK_SET);
// Read locator signature
if (err == MZ_OK)
{
err = mz_stream_read_uint32(stream, &value32);
if (value32 != ZIP64ENDLOCHEADERMAGIC)
if (value32 != MZ_ZIP_MAGIC_ENDLOCHEADER64)
err = MZ_FORMAT_ERROR;
}
// Number of the disk with the start of the zip64 end of central directory
@ -190,7 +171,7 @@ static int32_t mz_zip_search_zip64_cd(void *stream, const uint64_t end_central_o
if (err == MZ_OK)
{
err = mz_stream_read_uint32(stream, &value32);
if (value32 != ZIP64ENDHEADERMAGIC)
if (value32 != MZ_ZIP_MAGIC_ENDHEADER64)
err = MZ_FORMAT_ERROR;
}
@ -407,7 +388,7 @@ extern int ZEXPORT mz_zip_entry_open(void *handle, const mz_zip_file *file_info,
uint16_t version_needed = 0;
int16_t err = MZ_OK;
#ifdef NOCRYPT
#if !defined(HAVE_CRYPT) && !defined(HAVE_AES)
if (password != NULL)
return MZ_PARAM_ERROR;
#endif
@ -476,13 +457,13 @@ extern int ZEXPORT mz_zip_entry_open(void *handle, const mz_zip_file *file_info,
// Write the local header
if (err == MZ_OK)
err = mz_stream_write_uint32(zip->stream, (uint32_t)LOCALHEADERMAGIC);
err = mz_stream_write_uint32(zip->stream, (uint32_t)MZ_ZIP_MAGIC_LOCALHEADER);
version_needed = 20;
if (zip->file_info.zip64)
version_needed = 45;
#ifdef HAVE_AES
if ((zip->file_info.flag & 1) && (zip->crypt_info.aes))
if ((zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) && (zip->crypt_info.aes))
version_needed = 51;
#endif
#ifdef HAVE_LZMA
@ -497,7 +478,7 @@ extern int ZEXPORT mz_zip_entry_open(void *handle, const mz_zip_file *file_info,
if (err == MZ_OK)
{
#ifdef HAVE_AES
if ((zip->file_info.flag & 1) && (zip->crypt_info.aes))
if ((zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) && (zip->crypt_info.aes))
err = mz_stream_write_uint16(zip->stream, MZ_AES_METHOD);
else
#endif
@ -519,7 +500,7 @@ extern int ZEXPORT mz_zip_entry_open(void *handle, const mz_zip_file *file_info,
{
uint16_t extrafield_size = zip->file_info.extrafield_local_size;
#ifdef HAVE_AES
if ((zip->file_info.flag & 1) && (zip->crypt_info.aes))
if ((zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) && (zip->crypt_info.aes))
extrafield_size += 4 + 7;
#endif
if (zip->file_info.zip64)
@ -563,28 +544,19 @@ extern int ZEXPORT mz_zip_entry_open(void *handle, const mz_zip_file *file_info,
}
#endif
#ifndef NOCRYPT
if (err == Z_OK)
if ((err == Z_OK) && (zip->crypt_info.password != NULL))
{
if (zip->crypt_info.password == NULL)
{
mz_stream_passthru_create(&zip->crypt_stream);
mz_stream_set_base(zip->crypt_stream, zip->stream);
}
#ifdef HAVE_AES
else if (zip->crypt_info.aes)
if (zip->crypt_info.aes)
{
mz_stream_aes_create(&zip->crypt_stream);
mz_stream_aes_set_password(zip->crypt_stream, zip->crypt_info.password);
mz_stream_set_base(zip->crypt_stream, zip->stream);
if (mz_stream_open(zip->crypt_stream, NULL, MZ_STREAM_MODE_WRITE) != MZ_OK)
err = MZ_INTERNAL_ERROR;
}
else
#endif
{
#ifdef HAVE_CRYPT
uint8_t verify1 = 0;
uint8_t verify2 = 0;
@ -597,14 +569,25 @@ extern int ZEXPORT mz_zip_entry_open(void *handle, const mz_zip_file *file_info,
mz_stream_crypt_create(&zip->crypt_stream);
mz_stream_crypt_set_password(zip->crypt_stream, zip->crypt_info.password);
mz_stream_crypt_set_verify(zip->crypt_stream, verify1, verify2);
#endif
}
}
if (err == MZ_OK)
{
if (zip->crypt_stream == NULL)
{
mz_stream_passthru_create(&zip->crypt_stream);
mz_stream_set_base(zip->crypt_stream, zip->stream);
}
else
{
mz_stream_set_base(zip->crypt_stream, zip->stream);
if (mz_stream_open(zip->crypt_stream, NULL, MZ_STREAM_MODE_WRITE) != MZ_OK)
err = MZ_INTERNAL_ERROR;
}
}
#endif
if (err == MZ_OK)
{
@ -669,10 +652,8 @@ extern int ZEXPORT mz_zip_entry_write(void *handle, const void *buf, uint32_t le
if (zip->entry_opened == 0)
return MZ_PARAM_ERROR;
if (mz_stream_write(zip->crc32_stream, buf, len) == MZ_STREAM_ERROR)
return MZ_STREAM_ERROR;
return MZ_OK;
return mz_stream_write(zip->crc32_stream, buf, len);
}
extern int ZEXPORT mz_zip_entry_close_raw(void *handle, uint64_t uncompressed_size, uint32_t crc32)
@ -721,7 +702,7 @@ extern int ZEXPORT mz_zip_entry_close_raw(void *handle, uint64_t uncompressed_si
// Write data descriptor
if (err == MZ_OK)
err = mz_stream_write_uint32(zip->stream, (uint32_t)DATADESCRIPTORMAGIC);
err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_DATADESCRIPTOR);
if (err == MZ_OK)
err = mz_stream_write_uint32(zip->stream, crc32);
if (err == MZ_OK)
@ -772,7 +753,7 @@ extern int ZEXPORT mz_zip_entry_close_raw(void *handle, uint64_t uncompressed_si
if (zip->file_info.comment != NULL)
comment_size = (uint16_t)strlen(zip->file_info.comment);
mz_stream_write_uint32(zip->cd_stream, (uint32_t)CENTRALHEADERMAGIC);
mz_stream_write_uint32(zip->cd_stream, MZ_ZIP_MAGIC_CENTRALHEADER);
mz_stream_write_uint16(zip->cd_stream, zip->file_info.version_madeby);
mz_stream_write_uint16(zip->cd_stream, version_needed);
mz_stream_write_uint16(zip->cd_stream, zip->file_info.flag);
@ -899,7 +880,7 @@ extern int ZEXPORT mz_zip_close(void *handle, const char *global_comment, uint16
{
uint64_t zip64_eocd_pos_inzip = mz_stream_tell(zip->stream);
err = mz_stream_write_uint32(zip->stream, (uint32_t)ZIP64ENDHEADERMAGIC);
err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDHEADER64);
// Size of this 'zip64 end of central directory'
if (err == MZ_OK)
@ -933,7 +914,7 @@ extern int ZEXPORT mz_zip_close(void *handle, const char *global_comment, uint16
err = mz_stream_write_uint64(zip->stream, cd_pos);
}
if (err == MZ_OK)
err = mz_stream_write_uint32(zip->stream, (uint32_t)ZIP64ENDLOCHEADERMAGIC);
err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDLOCHEADER64);
// Number of the disk with the start of the central directory
if (err == MZ_OK)
@ -953,7 +934,7 @@ extern int ZEXPORT mz_zip_close(void *handle, const char *global_comment, uint16
// Signature
if (err == MZ_OK)
err = mz_stream_write_uint32(zip->stream, (uint32_t)ENDHEADERMAGIC);
err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDHEADER);
// Number of this disk
if (err == MZ_OK)
err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->number_disk_with_CD);

View File

@ -29,20 +29,6 @@ extern "C" {
/***************************************************************************/
#ifndef MZ_COMPRESS_METHOD
# define MZ_COMPRESS_METHOD_RAW (0)
# define MZ_COMPRESS_METHOD_DEFLATE (8)
# define MZ_COMPRESS_METHOD_BZIP2 (12)
# define MZ_COMPRESS_METHOD_LZMA (14)
#endif
#define MZ_COMPRESS_LEVEL_DEFAULT (-1)
#define MZ_COMPRESS_WINDOW_BITS_DEFAULT (0)
#define MZ_COMPRESS_MEM_LEVEL_DEFAULT (0)
#define MZ_COMPRESS_STRATEGY_DEFAULT (-1)
/***************************************************************************/
typedef struct mz_zip_file_s
{
uint32_t dos_date; // ms-dos date and time