File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ pub fn (mut zentry Zip) crc32() u32 {
183183
184184// write_entry compresses an input buffer for the current zip entry.
185185pub fn (mut zentry Zip) write_entry (data []u8 ) ! {
186- if int (data[0 ] & 0xff ) == - 1 {
186+ if data.len > 0 && int (data[0 ] & 0xff ) == - 1 {
187187 return error ('szip: cannot write entry' )
188188 }
189189 res := C.zip_entry_write (zentry, data.data, data.len)
Original file line number Diff line number Diff line change @@ -170,3 +170,11 @@ fn test_zip_folder_omit_empty_directories() {
170170 assert (os.read_file (fpath5 )! ) == '5'
171171 assert (os.read_file (fpath6 )! ) == '6'
172172}
173+
174+ fn test_zip_folder_empty_file () {
175+ cleanup ()
176+ os.mkdir_all (test_path)!
177+ os.write_file ('${test_path }/test.txt' , '' )! // Empty file
178+ szip.zip_folder (test_path, test_dir_zip)!
179+ assert os.exists (test_dir_zip)
180+ }
You can’t perform that action at this time.
0 commit comments