--- a/ReadWriteStream.st Thu Mar 12 18:10:39 2015 +0100
+++ b/ReadWriteStream.st Thu Mar 12 18:12:57 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -179,6 +181,35 @@
position := 0.
! !
+!ReadWriteStream methodsFor:'misc functions'!
+
+copyToEndInto:aWriteStream bufferSize:bufferSize
+ "read from the receiver, and write all data up to the end to another stream.
+ Return the number of bytes which have been transferred.
+ Redefined here to avoid intermediate buffers/garbage.
+ bufferSize does not matter here."
+
+ |cnt|
+
+ collection notNil ifTrue:[
+ aWriteStream nextPutAll:collection startingAt:position+1 to:readLimit.
+ cnt := readLimit - position.
+ position := readLimit.
+ ^ cnt.
+ ].
+ ^ super copyToEndInto:aWriteStream bufferSize:bufferSize.
+
+ "
+ |rs ws|
+
+ ws := #() writeStream.
+ rs := #( 1 2 3 4 ) readWriteStream.
+ rs next.
+ rs copyToEndInto:ws bufferSize:0.
+ ws contents.
+ "
+! !
+
!ReadWriteStream methodsFor:'queries'!
isReadable
@@ -196,10 +227,10 @@
!ReadWriteStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.37 2015-02-25 14:13:12 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.38 2015-03-12 17:12:57 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.37 2015-02-25 14:13:12 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.38 2015-03-12 17:12:57 stefan Exp $'
! !