# HG changeset patch # User ca # Date 1169025329 -3600 # Node ID 4dd5f9f30878d729bc5a4e56e0ae253d8e44f643 # Parent 47cd819e24af51f8e34b8759cb48ec92cb96fd44 atEnd fixed diff -r 47cd819e24af -r 4dd5f9f30878 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!