149 |
let cd_offset = read4_int ic in |
let cd_offset = read4_int ic in |
150 |
let comment_len = read2 ic in |
let comment_len = read2 ic in |
151 |
let comment = readstring ic comment_len in |
let comment = readstring ic comment_len in |
152 |
assert (magic = Int32.of_int 0x06054b50); |
assert (magic = 0x06054b50l); |
153 |
if disk_no <> 0 || cd_disk_no <> 0 then |
if disk_no <> 0 || cd_disk_no <> 0 then |
154 |
raise (Error(filename, "", "multi-disk ZIP files not supported")); |
raise (Error(filename, "", "multi-disk ZIP files not supported")); |
155 |
(cd_entries, cd_offset, comment) |
(cd_entries, cd_offset, comment) |
181 |
let name = readstring ic name_len in |
let name = readstring ic name_len in |
182 |
let extra = readstring ic extra_len in |
let extra = readstring ic extra_len in |
183 |
let comment = readstring ic comment_len in |
let comment = readstring ic comment_len in |
184 |
if magic <> Int32.of_int 0x02014b50 then |
if magic <> 0x02014b50l then |
185 |
raise (Error(filename, name, |
raise (Error(filename, name, |
186 |
"wrong file header in central directory")); |
"wrong file header in central directory")); |
187 |
if flags land 1 <> 0 then |
if flags land 1 <> 0 then |
248 |
let uncompr_size = read4_int ic in |
let uncompr_size = read4_int ic in |
249 |
let filename_len = read2 ic in |
let filename_len = read2 ic in |
250 |
let extra_len = read2 ic in |
let extra_len = read2 ic in |
251 |
if magic <> Int32.of_int 0x04034b50 then |
if magic <> 0x04034b50l then |
252 |
raise (Error(ifile.if_filename, e.filename, "wrong local file header")); |
raise (Error(ifile.if_filename, e.filename, "wrong local file header")); |
253 |
(* Could validate information read against directory entry, but |
(* Could validate information read against directory entry, but |
254 |
what the heck *) |
what the heck *) |
366 |
(* Close a ZIP file for writing. Add central directory. *) |
(* Close a ZIP file for writing. Add central directory. *) |
367 |
|
|
368 |
let write_directory_entry oc e = |
let write_directory_entry oc e = |
369 |
write4 oc (Int32.of_int 0x02014b50); (* signature *) |
write4 oc (0x02014b50l); (* signature *) |
370 |
let version = match e.methd with Stored -> 10 | Deflated -> 20 in |
let version = match e.methd with Stored -> 10 | Deflated -> 20 in |
371 |
write2 oc version; (* version made by *) |
write2 oc version; (* version made by *) |
372 |
write2 oc version; (* version needed to extract *) |
write2 oc version; (* version needed to extract *) |
397 |
let num_entries = List.length ofile.of_entries in |
let num_entries = List.length ofile.of_entries in |
398 |
if num_entries >= 0x10000 then |
if num_entries >= 0x10000 then |
399 |
raise(Error(ofile.of_filename, "", "too many entries")); |
raise(Error(ofile.of_filename, "", "too many entries")); |
400 |
write4 oc (Int32.of_int 0x06054b50); (* signature *) |
write4 oc (0x06054b50l); (* signature *) |
401 |
write2 oc 0; (* disk number *) |
write2 oc 0; (* disk number *) |
402 |
write2 oc 0; (* number of disk with central dir *) |
write2 oc 0; (* number of disk with central dir *) |
403 |
write2 oc num_entries; (* # entries in this disk *) |
write2 oc num_entries; (* # entries in this disk *) |
421 |
raise(Error(ofile.of_filename, filename, "comment too long")); |
raise(Error(ofile.of_filename, filename, "comment too long")); |
422 |
let oc = ofile.of_channel in |
let oc = ofile.of_channel in |
423 |
let pos = pos_out oc in |
let pos = pos_out oc in |
424 |
write4 oc (Int32.of_int 0x04034b50); (* signature *) |
write4 oc (0x04034b50l); (* signature *) |
425 |
let version = if level = 0 then 10 else 20 in |
let version = if level = 0 then 10 else 20 in |
426 |
write2 oc version; (* version needed to extract *) |
write2 oc version; (* version needed to extract *) |
427 |
write2 oc 8; (* flags *) |
write2 oc 8; (* flags *) |
451 |
|
|
452 |
let add_data_descriptor ofile crc compr_size uncompr_size entry = |
let add_data_descriptor ofile crc compr_size uncompr_size entry = |
453 |
let oc = ofile.of_channel in |
let oc = ofile.of_channel in |
454 |
write4 oc (Int32.of_int 0x08074b50); (* signature *) |
write4 oc (0x08074b50l); (* signature *) |
455 |
write4 oc crc; (* CRC *) |
write4 oc crc; (* CRC *) |
456 |
write4_int oc compr_size; (* compressed size *) |
write4_int oc compr_size; (* compressed size *) |
457 |
write4_int oc uncompr_size; (* uncompressed size *) |
write4_int oc uncompr_size; (* uncompressed size *) |