Stream.st
changeset 23893 0273fd434361
parent 23892 99bbfe4d920f
child 23896 c00000f683b6
--- a/Stream.st	Wed Mar 13 12:01:21 2019 +0100
+++ b/Stream.st	Wed Mar 13 12:51:41 2019 +0100
@@ -754,14 +754,11 @@
 
     "read loop: read required bytes"
     [
-        |readCount|
-
-        readCount := self nextAvailable:bytesLeft into:buffer startingAt:1.
-        bytesLeft := bytesLeft - readCount.
-
-        readCount > 0 ifTrue:[
-            |writeCount|
-
+        |readCount writeCount|
+
+        readCount := self nextAvailable:(bytesLeft min:bufferSize) into:buffer startingAt:1.
+        readCount ~~ 0 ifTrue:[
+            bytesLeft := bytesLeft - readCount.
             writeCount := 0.
             "write loop: write until all is written"
             [
@@ -789,7 +786,16 @@
     freeBuffer ifTrue:[ buffer free ].
     ^ countWritten.
 
+    "
+        |s|
+        s := WriteStream on:(String new:100).
+        '/etc/passwd' asFilename readStream
+            copy:100 into:s bufferSize:10.
+        s contents
+    "
+
     "Modified: / 13-03-2019 / 12:00:46 / Claus Gittinger"
+    "Modified: / 13-03-2019 / 12:50:48 / Stefan Vogel"
 !
 
 copyToEndFrom:inStream