+2009-05-14 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * library/zipvfs.tcl: Handle directory names that include
+ * tests/vfsZip.test: glob chars. Added some tests.
+ * win/makefile.vc: fix running the tests.
+
2009-02-06 Andreas Kupries <andreask@activestate.com>
* library/vfs.tcl.in: New file encapsulating the package load
upvar #0 zip::$fd.toc toc
if { $path == "." || $path == "" } {
- set path [string tolower $pat]
+ set path [set tmp [string tolower $pat]]
} else {
- set path [string tolower $path]
+ set globmap [list "\[" "\\\[" "*" "\\*" "?" "\\?"]
+ set tmp [string tolower $path]
+ set path [string map $globmap $tmp]
if {$pat != ""} {
+ append tmp /[string tolower $pat]
append path /[string tolower $pat]
}
}
- set depth [llength [file split $path]]
+ # file split can be confused by the glob quoting so split tmp string
+ set depth [llength [file split $tmp]]
- #puts stderr "getdir $fd $path $depth $pat [array names toc $path]"
+ #vfs::log "getdir $fd $path $depth $pat [array names toc $path]"
if {$depth} {
set ret {}
foreach key [array names toc $path] {
eval exec [auto_execok zip] [list -r zipfs.zip zipfs.test]
eval exec [auto_execok zip] [list zipnest.zip zipfs.zip]
+ file mkdir zipglob.test
+ makeFile {Glob one} "zipglob.test/one\[1\].txt"
+ makeFile {Glob two} "zipglob.test/two \[2\].txt"
+ file mkdir zipglob.test/a\[0\]
+ makeFile {Glob three} "zipglob.test/a\[0\]/three.txt"
+ eval exec [auto_execok zip] [list -r zipglob.zip zipglob.test]
+
testConstraint zipcat [expr {![catch {
makeFile {} zipcat.zip
set f [open zipcat.zip w] ; fconfigure $f -translation binary
vfs::unmount local
} -result {One.txt Two.txt}
+test vfsZip-1.12 "globby filenames" -constraints {zipfs zipexe} -setup {
+ vfs::zip::Mount zipglob.zip local
+} -body {
+ glob -type f -tail -directory local/zipglob.test *
+} -cleanup {
+ vfs::unmount local
+} -result [list "one\[1\].txt" "two \[2\].txt"]
+
+test vfsZip-1.13 "globby filenames" -constraints {zipfs zipexe} -setup {
+ vfs::zip::Mount zipglob.zip local
+} -body {
+ set result {}
+ foreach file [glob -type f -directory local/zipglob.test *] {
+ set f [open $file r]
+ lappend result [string trim [read $f]]
+ }
+ set result
+} -cleanup {
+ vfs::unmount local
+} -result [list "Glob one" "Glob two"]
+
+test vfsZip-1.14 "globby subdir" -constraints {zipfs zipexe} -setup {
+ vfs::zip::Mount zipglob.zip local
+} -body {
+ glob -type d -tail -directory local/zipglob.test *
+} -cleanup {
+ vfs::unmount local
+} -result [list "a\[0\]"]
+
+test vfsZip-1.15 "globby subdir" -constraints {zipfs zipexe} -setup {
+ vfs::zip::Mount zipglob.zip local
+} -body {
+ set result {}
+ foreach dir [glob -type d -directory local/zipglob.test *] {
+ lappend result [glob -nocomplain -tail -directory $dir *]
+ }
+ set result
+} -cleanup {
+ vfs::unmount local
+} -returnCodes {ok error} -result {three.txt}
+
test vfsZip-2.0 "nested stat file" -constraints {zipfs zipexe} -setup {
vfs::zip::Mount zipnest.zip local
unset -nocomplain stat
# cleanup
if {[testConstraint zipfs] && [testConstraint zipexe]} {
file delete -force zipfs.test
+ file delete -force zipglob.test
file delete zipfs.zip
file delete zipnest.zip
+ file delete zipglob.zip
}
tcltest::cleanupTests
return