--- a/ZipStream.st Fri Jun 21 16:42:27 2002 +0200
+++ b/ZipStream.st Mon Jun 24 09:11:21 2002 +0200
@@ -3,7 +3,7 @@
"{ Package: 'ca:Compress' }"
Stream subclass:#ZipStream
- instanceVariableNames:'onStream hitEOF binary readPosition writePosition readLimit mode inputBytes outputBytes zstream'
+ instanceVariableNames:'onStream hitEOF binary position readLimit mode inputBytes outputBytes zstream'
classVariableNames:'Z_FINISH Z_NO_FLUSH Z_SYNC_FLUSH Z_FULL_FLUSH Z_DEFLATED
Z_DEFAULT_COMPRESSION Z_DEFAULT_LEVEL Z_BEST_COMPRESSION
Z_DEF_MEM_LEVEL Z_DEFAULT_STRATEGY Z_FILTERED Z_HUFFMAN_ONLY
@@ -286,6 +286,24 @@
Stream streamErrorSignal raiseErrorString:(self class name , ': ', error).
! !
+!ZipStream methodsFor:'finalization'!
+
+executor
+ "redefined to return a lightweight copy
+ - all we need is the memory handle.
+ "
+ ^ self class basicNew finalizeCopy:zstream.
+!
+
+finalize
+ self zclose.
+ zstream := nil.
+!
+
+finalizeCopy:aZStream
+ zstream := aZStream.
+! !
+
!ZipStream methodsFor:'low level'!
zset_avail_in:count
@@ -326,7 +344,7 @@
hitEOF := true.
zstream ifNil:[^ self].
-
+ self unregisterForFinalization.
%{
OBJ _zstreamObj = __INST( zstream );
@@ -584,7 +602,7 @@
outputBytes := ExternalBytes unprotectedNew:8192.
inputBytes := ExternalBytes unprotectedNew:8192.
outTotal := outputBytes size.
- readLimit := readPosition := writePosition := 0.
+ readLimit := position := 0.
binary := false.
%{
zstream_s * _zstream = (zstream_s *) malloc( sizeof(zstream_s) );
@@ -621,6 +639,7 @@
%}.
zstream ifNil:[ self zerror:'cannot allocate zbuffer' ].
hitEOF := false.
+ self registerForFinalization.
! !
!ZipStream methodsFor:'private'!
@@ -773,7 +792,7 @@
hitEOF == true ifTrue:[^ nil].
- readPosition == readLimit ifTrue:[
+ position == readLimit ifTrue:[
[ (readLimit := self zinflate) == 0 ] whileTrue:[ |n|
n := onStream nextBytes:(inputBytes size) into:inputBytes startingAt:1.
@@ -786,10 +805,10 @@
hitEOF := true.
^ nil
].
- readPosition := 0.
+ position := 0.
].
- readPosition := readPosition + 1.
- byte := outputBytes at:readPosition.
+ position := position + 1.
+ byte := outputBytes at:position.
binary ifTrue:[^ byte ].
^ Character value:byte
@@ -840,9 +859,9 @@
self isWriteOpen ifFalse:[ ^ self ].
- self zset_avail_in:writePosition.
- writePosition := 0.
- continue := true.
+ self zset_avail_in:position.
+ position := 0.
+ continue := true.
[continue] whileTrue:[
self zflush.
@@ -883,9 +902,9 @@
bad: ;
%}.
byte ifNil:[self invalidArguments].
- writePosition == inputBytes size ifTrue:[ self flush ].
- writePosition := writePosition + 1.
- inputBytes at:writePosition put:byte.
+ position == inputBytes size ifTrue:[ self flush ].
+ position := position + 1.
+ inputBytes at:position put:byte.
!
nextPutByte:aByte
@@ -903,6 +922,6 @@
!ZipStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.10 2002-06-21 14:42:27 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.11 2002-06-24 07:11:21 ca Exp $'
! !
ZipStream initialize!