ExternalStream.st
branchjv
changeset 18060 3708e12e9aa8
parent 18028 e39da2aa21bc
parent 15254 1d0a262c1743
child 18063 4a8226cd76ab
--- a/ExternalStream.st	Tue May 21 21:58:09 2013 +0100
+++ b/ExternalStream.st	Fri May 24 18:52:05 2013 +0100
@@ -3204,6 +3204,34 @@
 
 !ExternalStream methodsFor:'non homogenous reading'!
 
+next:count into:anObject startingAt:start
+    "read the next count bytes into an object and return the number of
+     bytes read or the number of bytes read, if EOF is encountered before.
+     If the receiver is some socket/pipe-like stream, an exception
+     is raised if the connection is broken.
+
+     Warning: if used with a pipe/socket, this blocks until the requested number
+     of bytes have been read. See #nextAvailableBytes:into:startingAt:
+     to only read whats there.
+
+     Notice, that in contrast to other methods,
+     this does NOT return nil on EOF, but the actual count.
+     Thus allowing read of partial blocks.
+
+     The object must have non-pointer indexed instvars
+     (i.e. it must be a ByteArray, String, Float- or DoubleArray),
+     or an externalBytes object (with known size).
+     If anObject is a string or byteArray and reused, this provides the
+     fastest possible physical I/O (since no new objects are allocated).
+
+     Use with care - non object oriented I/O.
+     Warning: in general, you cannot use this method to pass data from other
+     architectures (unless you prepared the buffer with care),
+     since it does not care for byte order or float representation."
+
+    ^ self nextBytes:count into:anObject startingAt:start
+!
+
 nextAvailable:count
     "return the next count elements of the stream as aCollection.
      If the stream reaches the end before count elements have been read,
@@ -5735,11 +5763,11 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.361 2013-03-11 09:48:06 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.362 2013-05-15 21:49:08 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.361 2013-03-11 09:48:06 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.362 2013-05-15 21:49:08 cg Exp $'
 ! !