File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ pub fn (mut zentry Zip) crc32() u32 {
183
183
184
184
// write_entry compresses an input buffer for the current zip entry.
185
185
pub 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 {
187
187
return error ('szip: cannot write entry' )
188
188
}
189
189
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() {
170
170
assert (os.read_file (fpath5 )! ) == '5'
171
171
assert (os.read_file (fpath6 )! ) == '6'
172
172
}
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