+2008-12-22 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * library/mk4vfs.tcl: Fix vfs::ztream to support 8.6 core zlib
+ * library/vfslib.tcl:
+
2008-12-12 Pat Thoyts <patthoyts@users.sourceforge.net>
* library/zipvfs.tcl: Cleaned up the zip stream read function to
if { $sb(csize) != $sb(size) } {
if {$::mk4vfs::zstreamed} {
set fd [mk::channel $sb(ino) contents r]
- fconfigure $fd -translation binary
set fd [vfs::zstream decompress $fd $sb(csize) $sb(size)]
} else {
set fd [vfs::memchan]
}
variable ::vfs::zseq 0 ;# used to generate temp zstream cmd names
- proc vfs::zstream {mode ifd clen ilen} {
- set cname _zstream_[incr ::vfs::zseq]
- zlib s$mode $cname
- set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode]
- set fd [rechan $cmd 2]
- set ::vfs::_zstream_pos($fd) 0
- return $fd
+
+ # vfs::zstream --
+ # wrapper to manage a stacked zlib channel. If we have the core
+ # zlib implementation then make use of that. Otherwise we can use
+ # rechan and the tclkit zlib package to do the same thing.
+ #
+ # mode - compress or decompress
+ # ifd - input channel (should be binary)
+ # clen - size of compressed data in bytes
+ # ilen - size of decompressed data in bytes
+ # Result:
+ # A stacked channel then handles compression for us.
+ #
+ if {[package vsatisfies [package provide Tcl] 8.6]} {
+ proc vfs::zstream {mode ifd clen ilen} {
+ return [zlib push $mode $ifd]
+ }
+ } else {
+ proc vfs::zstream {mode ifd clen ilen} {
+ set cname _zstream_[incr ::vfs::zseq]
+ zlib s$mode $cname
+ fconfigure $fd -translation binary
+ set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode]
+ set fd [rechan $cmd 2]
+ set ::vfs::_zstream_pos($fd) 0
+ return $fd
+ }
}
}