Posted to tcl by patthoyts at Tue Mar 10 13:00:19 GMT 2009view raw

  1. Avoid using the core 8.6 zlib code for vfs::zstream until we can seek it.
  2. (used by mk4vfs)
  3.  
  4. Index: library/vfslib.tcl
  5. ===================================================================
  6. RCS file: /cvsroot/tclvfs/tclvfs/library/vfslib.tcl,v
  7. retrieving revision 1.10
  8. diff -u -r1.10 vfslib.tcl
  9. --- library/vfslib.tcl 22 Jan 2009 15:10:10 -0000 1.10
  10. +++ library/vfslib.tcl 19 Feb 2009 20:05:52 -0000
  11. @@ -34,7 +34,7 @@
  12. # Also provide an abstract zlib streaming channel transform using the core
  13. # zlib command (8.6) or the tclkit zlib package.
  14. #
  15. -if {[package vsatisfies [package provide Tcl] 8.6]} {
  16. +if {[package vsatisfies [package provide Tcl] 8.9]} {
  17.  
  18. proc vfs::zstream {mode ifd clen ilen} {
  19. return [zlib push $mode $ifd]
  20. @@ -251,32 +251,24 @@
  21.  
  22. variable ::vfs::zseq 0 ;# used to generate temp zstream cmd names
  23.  
  24. - # vfs::zstream --
  25. - # wrapper to manage a stacked zlib channel. If we have the core
  26. - # zlib implementation then make use of that. Otherwise we can use
  27. - # rechan and the tclkit zlib package to do the same thing.
  28. + # vfs::zstream --
  29. + #
  30. + # Create a read-only seekable compressed channel using rechan and
  31. + # the streaming mode of zlib.
  32. #
  33. # mode - compress or decompress
  34. # ifd - input channel (should be binary)
  35. # clen - size of compressed data in bytes
  36. # ilen - size of decompressed data in bytes
  37. - # Result:
  38. - # A stacked channel then handles compression for us.
  39. #
  40. - if {[package vsatisfies [package provide Tcl] 8.6]} {
  41. - proc vfs::zstream {mode ifd clen ilen} {
  42. - return [zlib push $mode $ifd]
  43. - }
  44. - } else {
  45. - proc vfs::zstream {mode ifd clen ilen} {
  46. - set cname _zstream_[incr ::vfs::zseq]
  47. - zlib s$mode $cname
  48. - fconfigure $ifd -translation binary
  49. - set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode]
  50. - set fd [rechan $cmd 2]
  51. - set ::vfs::_zstream_pos($fd) 0
  52. - return $fd
  53. - }
  54. + proc vfs::zstream {mode ifd clen ilen} {
  55. + set cname _zstream_[incr ::vfs::zseq]
  56. + zlib s$mode $cname
  57. + fconfigure $ifd -translation binary
  58. + set cmd [list ::vfs::zstream_handler $cname $ifd $clen $ilen s$mode]
  59. + set fd [rechan $cmd 2]
  60. + set ::vfs::_zstream_pos($fd) 0
  61. + return $fd
  62. }
  63. }