mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
Fixed appending for zip spanning.
Added append mode cmake unit tests.
This commit is contained in:
parent
6b64b924af
commit
2ce1fe2732
@ -682,6 +682,15 @@ if(BUILD_UNIT_TEST)
|
||||
COMMAND minizip -x -o ${EXTRA_ARGS} -d out result.zip
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
|
||||
endif()
|
||||
add_test(NAME ${COMPRESS_METHOD_NAME}-append-${EXTRA_NAME}
|
||||
COMMAND minizip ${COMPRESS_METHOD_ARG} -a ${EXTRA_ARGS}
|
||||
result.zip single.txt
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
|
||||
if(NOT COMPRESS_ONLY)
|
||||
add_test(NAME ${COMPRESS_METHOD_NAME}-append-unzip-${EXTRA_NAME}
|
||||
COMMAND minizip -x -o ${EXTRA_ARGS} -d out result.zip
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
|
||||
endif()
|
||||
add_test(NAME ${COMPRESS_METHOD_NAME}-erase-${EXTRA_NAME}
|
||||
COMMAND minizip -o -e result.zip test.c test.h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test)
|
||||
|
@ -223,12 +223,12 @@ int32_t mz_stream_split_open(void *stream, const char *path, int32_t mode)
|
||||
strncpy(split->path_disk, path, split->path_disk_size - 1);
|
||||
split->path_disk[split->path_disk_size - 1] = 0;
|
||||
|
||||
if (mode & MZ_OPEN_MODE_WRITE)
|
||||
if ((mode & MZ_OPEN_MODE_WRITE) && ((mode & MZ_OPEN_MODE_APPEND) == 0))
|
||||
{
|
||||
number_disk = 0;
|
||||
split->current_disk = -1;
|
||||
}
|
||||
else if (mode & MZ_OPEN_MODE_READ)
|
||||
else
|
||||
{
|
||||
number_disk = -1;
|
||||
split->current_disk = 0;
|
||||
|
6
mz_zip.c
6
mz_zip.c
@ -1372,6 +1372,12 @@ int32_t mz_zip_open(void *handle, void *stream, int32_t mode)
|
||||
/* If no central directory, append new zip to end of file */
|
||||
err = mz_stream_seek(zip->stream, 0, MZ_SEEK_END);
|
||||
}
|
||||
|
||||
if (zip->disk_number_with_cd > 0)
|
||||
{
|
||||
/* Move to last disk to begin appending */
|
||||
mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, zip->disk_number_with_cd - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
1
test/single.txt
Normal file
1
test/single.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
Loading…
x
Reference in New Issue
Block a user