diff --git a/CMakeLists.txt b/CMakeLists.txt index 71b5f83..f1049a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/mz_strm_split.c b/mz_strm_split.c index 623fb8b..bf5a1ce 100644 --- a/mz_strm_split.c +++ b/mz_strm_split.c @@ -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; diff --git a/mz_zip.c b/mz_zip.c index fe8f131..58e3d6f 100644 --- a/mz_zip.c +++ b/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 { diff --git a/test/single.txt b/test/single.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/test/single.txt @@ -0,0 +1 @@ +1 \ No newline at end of file