Differences From Artifact [f8be70e066]:
- File
kitsh/buildsrc/kitsh-0.0/zipvfs.tcl
— part of check-in
[77e40265de]
at
2010-09-26 04:49:35
on branch trunk
— Updated issue with opening directory
Updated to not panic if native encodings cannot be found (user: rkeene, size: 14120) [annotate] [blame] [check-ins using]
To Artifact [8fe7ed4f05]:
- File kitsh/buildsrc/kitsh-0.0/zipvfs.tcl — part of check-in [c0cb33bec5] at 2010-09-28 21:52:33 on branch trunk — Fixed issue with vfs::zip opening zip files smaller than 512b, fixes issue [0c5bcad642] (user: rkeene, size: 14293) [annotate] [blame] [check-ins using]
349 349 # ; # a buffer boundary, nor the header itself 350 350 } else { 351 351 break 352 352 } 353 353 } 354 354 355 355 set hdr [string range $hdr [expr $pos + 4] [expr $pos + 21]] 356 - set pos [expr [tell $fd] + $pos - 512] 356 + 357 + set seekstart [expr {[tell $fd] - 512}] 358 + if {$seekstart < 0} { 359 + set seekstart 0 360 + } 361 + set pos [expr {$seekstart + $pos}] 357 362 358 363 binary scan $hdr ssssiis \ 359 364 cb(ndisk) cb(cdisk) \ 360 365 cb(nitems) cb(ntotal) \ 361 366 cb(csize) cb(coff) \ 362 367 cb(comment) 363 368 ................................................................................ 364 369 set cb(ndisk) [u_short $cb(ndisk)] 365 370 set cb(nitems) [u_short $cb(nitems)] 366 371 set cb(ntotal) [u_short $cb(ntotal)] 367 372 set cb(comment) [u_short $cb(comment)] 368 373 369 374 # Compute base for situations where ZIP file 370 375 # has been appended to another media (e.g. EXE) 371 - set cb(base) [expr { $pos - $cb(csize) - $cb(coff) }] 376 + set base [expr { $pos - $cb(csize) - $cb(coff) }] 377 + if {$base < 0} { 378 + set base 0 379 + } 380 + set cb(base) $base 372 381 } 373 382 374 383 proc zip::TOC {fd arr} { 375 384 upvar #0 zip::$fd cb 376 385 upvar 1 $arr sb 377 386 378 387 set buf [read $fd 46]