+2004-06-29 Vince Darley <vincentdarley@sourceforge.net>
+
+ * library/zipvfs.tcl: fix to bug finding zip header (reported on
+ Tcl'ers wiki).
+
2004-06-09 Jeff Hobbs <jeffh@ActiveState.com>
* Makefile.in: corrected targets that use 'for' over what may be
proc zip::EndOfArchive {fd arr} {
upvar 1 $arr cb
- seek $fd -22 end
- set pos [tell $fd]
- set hdr [read $fd 22]
+ seek $fd -512 end
+ set hdr [read $fd 512]
+ set pos [string first "PK\05\06" $hdr]
+ if {$pos == -1} {
+ error "no header found"
+ }
+ set hdr [string range $hdr [expr $pos + 4] [expr $pos + 21]]
+ set pos [expr [tell $fd] + $pos - 512]
- binary scan $hdr A4ssssiis xhdr \
+ binary scan $hdr ssssiis \
cb(ndisk) cb(cdisk) \
cb(nitems) cb(ntotal) \
cb(csize) cb(coff) \
- cb(comment)
-
- if { ![string equal "PK\05\06" $xhdr]} {
- error "bad header"
- }
+ cb(comment)
set cb(ndisk) [u_short $cb(ndisk)]
set cb(nitems) [u_short $cb(nitems)]