atEnd fixed
authorca
Wed, 17 Jan 2007 10:15:29 +0100
changeset 1829 4dd5f9f30878
parent 1828 47cd819e24af
child 1830 b323fca72bc4
atEnd fixed
CompressionStream.st
--- a/CompressionStream.st	Tue Jan 16 17:21:51 2007 +0100
+++ b/CompressionStream.st	Wed Jan 17 10:15:29 2007 +0100
@@ -306,7 +306,7 @@
 atEnd
     "return true if the end of the compressed input stream has been reached"
 
-    ^ hitEOF ~~ false
+    ^ self canReadWithoutBlocking not
 !
 
 canReadWithoutBlocking
@@ -314,6 +314,8 @@
      false if the stream is at end.
      updates the readLimit and position"
 
+    |n|
+
     mode == #readonly ifFalse:[
         self errorWriteOnly
     ].
@@ -321,12 +323,11 @@
 
     position >= readLimit ifTrue:[
         [(readLimit := self zinflate) == 0] whileTrue:[ 
-            |n|
             n := onStream nextBytes:(inputBytes size) into:inputBytes startingAt:1.
+
             n == 0 ifTrue:[
                 hitEOF := true.
                 ^ false
-"/                self pastEndRead
             ].
             self zset_avail_in:n.
         ].
@@ -484,10 +485,10 @@
         ^ self errorNotOpen
     ].
 
-    onStream := aStream.    
+    onStream    := aStream.    
     mode        := aMode.
-    outputBytes := ExternalBytes unprotectedNew:8192.
-    inputBytes  := ExternalBytes unprotectedNew:8192.
+    outputBytes := ExternalBytes unprotectedNew:16384.
+    inputBytes  := ExternalBytes unprotectedNew:16384.
     readLimit   := position := 0.
     binary      := false.
 
@@ -515,21 +516,20 @@
 flush
     "flush the input and output buffer"
 
-    |continue|
+    |continue availOut|
 
     self isWritable ifFalse:[^ self].
     self zset_avail_in:position.
 
     position := 0.
 
-    [ 
-        |count|
-        continue := self zdeflate.
-        count := self zget_avail_out.
+    [   continue := self zdeflate.
+        availOut := self zget_avail_out.
 
-        count > 0 ifTrue:[
-            self onStreamPutBytes:count from:outputBytes
+        availOut > 0 ifTrue:[
+            self onStreamPutBytes:availOut from:outputBytes
         ].
+
     ] doWhile:[ continue == true ].
 !
 
@@ -539,12 +539,25 @@
     position == inputBytes size ifTrue:[self flush].
     position := position + 1.
     inputBytes at:position put:aByteOrCharacter asInteger.
+!
+
+nextPutAll:aCollection
+    |limit|
+
+    limit := inputBytes size.
+
+    aCollection do:[:aByteOrCharacter|
+        position == limit ifTrue:[self flush].
+        position := position + 1.
+        inputBytes at:position put:aByteOrCharacter asInteger.
+    ].
+    ^ aCollection
 ! !
 
 !CompressionStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/CompressionStream.st,v 1.20 2007-01-16 16:21:14 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/CompressionStream.st,v 1.21 2007-01-17 09:15:29 ca Exp $'
 ! !
 
 CompressionStream initialize!