From ef41ee16532ad299c7e5f388aef69179cbf9417a Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Sun, 22 Mar 2009 18:57:14 +0000 Subject: [PATCH] The 8.6 core zlib can't be used to implement the vfs::zstream as these channels need to be seekable and pushing zlib onto a channel makes it non-seeking. For now we can just disable this command as it is only used by tclkit when vfs::zstreamed is true. 8.6 tclkits will now set this false. TODO: make this command work with the core zlib. --- library/vfslib.tcl | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/library/vfslib.tcl b/library/vfslib.tcl index c2cdfbf..d44a8c9 100644 --- a/library/vfslib.tcl +++ b/library/vfslib.tcl @@ -31,14 +31,16 @@ if {[llength [info command zlib]] || ![catch {load "" zlib}]} { # Use 8.6 reflected channels or the rechan package in earlier versions to # provide a memory channel implementation. -# Also provide an abstract zlib streaming channel transform using the core -# zlib command (8.6) or the tclkit zlib package. # if {[package vsatisfies [package provide Tcl] 8.6]} { - proc vfs::zstream {mode ifd clen ilen} { - return [zlib push $mode $ifd] - } + # As the core zlib channel stacking make non-seekable channels we cannot + # implement vfs::zstream and this feature is disabled in tclkit boot.tcl + # when the command is not present (it is only used by mk4vfs) + # + #proc vfs::zstream {mode ifd clen ilen} { + # return -code error "vfs::zstream is unsupported with core zlib" + #} proc vfs::memchan {{filename {}}} { return [chan create {read write} \ [list [namespace origin _memchan_handler] $filename]] @@ -251,32 +253,24 @@ if {[package vsatisfies [package provide Tcl] 8.6]} { variable ::vfs::zseq 0 ;# used to generate temp zstream cmd names - # 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. + # vfs::zstream -- + # + # Create a read-only seekable compressed channel using rechan and + # the streaming mode of tclkit's zlib extension. # # 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 $ifd -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 - } + proc vfs::zstream {mode ifd clen ilen} { + set cname _zstream_[incr ::vfs::zseq] + zlib s$mode $cname + fconfigure $ifd -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 } } -- 2.23.0