From c0031c46d3b549990a37e0bea7cbcd94f6a6b504 Mon Sep 17 00:00:00 2001 From: sbredahl Date: Sat, 24 Sep 2016 08:06:17 +0200 Subject: [PATCH] added support for writing utf-8 filenames --- miniz.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/miniz.c b/miniz.c index 358143a..8958d70 100644 --- a/miniz.c +++ b/miniz.c @@ -4417,6 +4417,11 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, size_t archive_name_size; mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; MZ_FILE *pSrc_file = NULL; +#ifdef MINIZ_NO_UTF8 + mz_uint16 bit_flags = 0x0000; +#else + mz_uint16 bit_flags = 0x0800; +#endif // MINIZ_NO_UTF8 if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; @@ -4571,13 +4576,13 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) return MZ_FALSE; - if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) + if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date)) return MZ_FALSE; if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) return MZ_FALSE; - if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) + if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) return MZ_FALSE; pZip->m_total_files++;