fixes a variety of problems (e.g. recurisve 'file copy' in a
directory). Thanks to msofer for the detailed bug report and
test script.
+ * library/zipvfs.tcl:
+ * library/tarvfs.tcl: ensure archive channel is closed if an
+ error is encountered while trying to open it.
2003-07-03 Vince Darley <vincentdarley@sourceforge.net>
proc tar::open {path} {
set fd [::open $path]
- upvar #0 tar::$fd.toc toc
-
- fconfigure $fd -translation binary ;#-buffering none
-
- tar::TOC $fd sb toc
+
+ if {[catch {
+ upvar #0 tar::$fd.toc toc
+
+ fconfigure $fd -translation binary ;#-buffering none
+
+ tar::TOC $fd sb toc
+ } err]} {
+ close $fd
+ return -code error $err
+ }
+
return $fd
}
proc zip::open {path} {
set fd [::open $path]
- upvar #0 zip::$fd cb
- upvar #0 zip::$fd.toc toc
-
- fconfigure $fd -translation binary ;#-buffering none
-
- zip::EndOfArchive $fd cb
-
- seek $fd $cb(coff) start
-
- set toc(_) 0; unset toc(_); #MakeArray
+
+ if {[catch {
+ upvar #0 zip::$fd cb
+ upvar #0 zip::$fd.toc toc
- for { set i 0 } { $i < $cb(nitems) } { incr i } {
- zip::TOC $fd sb
+ fconfigure $fd -translation binary ;#-buffering none
+
+ zip::EndOfArchive $fd cb
- set sb(depth) [llength [file split $sb(name)]]
+ seek $fd $cb(coff) start
- set name [string tolower $sb(name)]
- set toc($name) [array get sb]
- FAKEDIR toc [file dirname $name]
+ set toc(_) 0; unset toc(_); #MakeArray
+
+ for { set i 0 } { $i < $cb(nitems) } { incr i } {
+ zip::TOC $fd sb
+
+ set sb(depth) [llength [file split $sb(name)]]
+
+ set name [string tolower $sb(name)]
+ set toc($name) [array get sb]
+ FAKEDIR toc [file dirname $name]
+ }
+ } err]} {
+ close $fd
+ return -code error $err
}
return $fd