PositionableStream.st
branchjv
changeset 19412 1e842c25e51e
parent 18260 e55af242e134
parent 19403 5accf347c2c1
child 19610 a9a6940944a9
--- a/PositionableStream.st	Tue Mar 22 08:03:27 2016 +0000
+++ b/PositionableStream.st	Wed Mar 23 07:50:28 2016 +0000
@@ -124,7 +124,6 @@
 ! !
 
 
-
 !PositionableStream methodsFor:'Compatibility-Dolphin'!
 
 endChunk
@@ -276,11 +275,10 @@
 
 !PositionableStream methodsFor:'misc functions'!
 
-copyToEndInto:aWriteStream bufferSize:bufferSize
+copyToEndInto:aWriteStream
     "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."
+     Redefined here to avoid intermediate buffers/garbage."
 
     |cnt|
 
@@ -290,6 +288,28 @@
         position := readLimit.
         ^ cnt.
     ].
+    ^ super copyToEndInto:aWriteStream.
+
+    "
+     |rs ws cnt|
+
+     ws := #() writeStream.
+     rs := #( 1 2 3 4 a nil true) readWriteStream.
+     rs next.
+     cnt := rs copyToEndInto:ws bufferSize:0.
+     Transcript show:cnt; show:' '; showCR:ws contents.
+    "
+!
+
+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."
+
+    collection notNil ifTrue:[
+        ^ self copyToEndInto:aWriteStream.
+    ].
     ^ super copyToEndInto:aWriteStream bufferSize:bufferSize.
 
     "
@@ -903,11 +923,11 @@
 !PositionableStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.171 2015-03-12 19:24:30 stefan Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/PositionableStream.st,v 1.171 2015-03-12 19:24:30 stefan Exp $'
+    ^ '$Header$'
 !
 
 version_HG