Index: kitdll/buildsrc/kitdll-0.0/boot.tcl ================================================================== --- kitdll/buildsrc/kitdll-0.0/boot.tcl +++ kitdll/buildsrc/kitdll-0.0/boot.tcl @@ -73,32 +73,38 @@ # loaded before this is run causing the root VFS to break catch { clock scan } # Load these, the original Tclkit does so it should be safe. uplevel #0 [list source [file join $tcl_mountpoint lib vfs vfsUtils.tcl]] + + # Set a maximum seek to avoid reading the entire DLL looking for a + # zip header + catch { + package require vfs::zip + set ::zip::max_header_seek 8192 + } # Now that the initialization is complete, mount the user VFS if needed ## Mount the VFS from the Shared Object if {[info exists ::initVFS] && [info exists ::tclKitFilename]} { catch { - package require vfs::zip - vfs::zip::Mount $::tclKitFilename "/.KITDLL_USER" lappend auto_path [file normalize "/.KITDLL_USER/lib"] } } ## Mount the VFS from executable if {[info exists ::initVFS]} { catch { - package require vfs::zip - vfs::zip::Mount [info nameofexecutable] "/.KITDLL_APP" lappend auto_path [file normalize "/.KITDLL_APP/lib"] } } + # Clean up + unset -nocomplain ::zip::max_header_seek + # Clean up after the kitInit.c:preInitCmd unset -nocomplain ::initVFS ::tclKitFilename } Index: kitsh/buildsrc/kitsh-0.0/zipvfs.tcl ================================================================== --- kitsh/buildsrc/kitsh-0.0/zipvfs.tcl +++ kitsh/buildsrc/kitsh-0.0/zipvfs.tcl @@ -330,10 +330,15 @@ # we have to extend the range of our search, possibly until we # have a large part of the archive in memory. We can fail only # after the whole file has been searched. set sz [tell $fd] + if {[info exists ::zip::max_header_seek]} { + if {$::zip::max_header_seek < $sz} { + set sz $::zip::max_header_seek + } + } set len 512 set at 512 while {1} { if {$sz < $at} {set n -$sz} else {set n -$at} Index: tclvfs/patches/all/tclvfs-20080503-zipvfs.diff ================================================================== --- tclvfs/patches/all/tclvfs-20080503-zipvfs.diff +++ tclvfs/patches/all/tclvfs-20080503-zipvfs.diff @@ -1,8 +1,8 @@ diff -uNr tclvfs-20080503.orig/library/zipvfs.tcl tclvfs-20080503-1rsk/library/zipvfs.tcl --- tclvfs-20080503.orig/library/zipvfs.tcl 2008-04-15 16:11:53.000000000 -0500 -+++ tclvfs-20080503-1rsk/library/zipvfs.tcl 2010-09-28 16:43:12.000000000 -0500 ++++ tclvfs-20080503-1rsk/library/zipvfs.tcl 2010-10-01 21:48:38.000000000 -0500 @@ -107,6 +107,10 @@ ::zip::stat $zipfd $name sb + if {$sb(ino) == -1} { @@ -42,11 +42,23 @@ } + return $res } -@@ -381,7 +385,12 @@ +@@ -360,6 +364,11 @@ + # after the whole file has been searched. + + set sz [tell $fd] ++ if {[info exists ::zip::max_header_seek]} { ++ if {$::zip::max_header_seek < $sz} { ++ set sz $::zip::max_header_seek ++ } ++ } + set len 512 + set at 512 + while {1} { +@@ -381,7 +390,12 @@ } set hdr [string range $hdr [expr $pos + 4] [expr $pos + 21]] - set pos [expr [tell $fd] + $pos - 512] + @@ -56,11 +68,11 @@ + } + set pos [expr {$seekstart + $pos}] binary scan $hdr ssssiis \ cb(ndisk) cb(cdisk) \ -@@ -396,10 +405,15 @@ +@@ -396,10 +410,15 @@ # Compute base for situations where ZIP file # has been appended to another media (e.g. EXE) - set cb(base) [expr { $pos - $cb(csize) - $cb(coff) }] + set base [expr { $pos - $cb(csize) - $cb(coff) }] @@ -73,23 +85,23 @@ proc zip::TOC {fd arr} { + upvar #0 zip::$fd cb upvar 1 $arr sb set buf [read $fd 46] -@@ -410,6 +424,8 @@ +@@ -410,6 +429,8 @@ flen elen clen sb(disk) sb(attr) \ sb(atx) sb(ino) + set sb(ino) [expr {$cb(base) + $sb(ino)}] + if { ![string equal "PK\01\02" $hdr] } { binary scan $hdr H* x error "bad central header: $x" -@@ -442,7 +458,7 @@ +@@ -442,7 +463,7 @@ zip::EndOfArchive $fd cb - seek $fd $cb(coff) start + seek $fd [expr {$cb(base) + $cb(coff)}] start set toc(_) 0; unset toc(_); #MakeArray