3673 "return the next count elements of the stream into aCollection at position pos." |
3673 "return the next count elements of the stream into aCollection at position pos." |
3674 |
3674 |
3675 ^ self nextAvailableBytes:count into:aCollection startingAt:pos. |
3675 ^ self nextAvailableBytes:count into:aCollection startingAt:pos. |
3676 ! |
3676 ! |
3677 |
3677 |
|
3678 nextAvailableBytes:count |
|
3679 "return the next count bytes of the stream as a byteArray. |
|
3680 If the stream reaches the end before count bytes have been read, |
|
3681 return what is available. (i.e. a shorter byteArray)." |
|
3682 |
|
3683 |buffer n| |
|
3684 |
|
3685 buffer := ByteArray uninitializedNew:count. |
|
3686 n := self nextAvailableBytes:count into:buffer startingAt:1. |
|
3687 n == 0 ifTrue:[ |
|
3688 ^ #[] |
|
3689 ]. |
|
3690 |
|
3691 n ~~ count ifTrue:[ |
|
3692 ^ buffer copyTo:n |
|
3693 ]. |
|
3694 ^ buffer. |
|
3695 |
|
3696 " |
|
3697 (ReadStream on:#(1 2 3 4 5)) nextAvailable:3 |
|
3698 (ReadStream on:#(1 2 3 4 5)) nextAvailable:10 |
|
3699 (ReadStream on:'hello') nextAvailable:3 |
|
3700 (ReadStream on:'hello') nextAvailable:10 |
|
3701 " |
|
3702 |
|
3703 "Modified: / 16.6.1998 / 15:52:41 / cg" |
|
3704 ! |
|
3705 |
3678 nextAvailableBytes:count into:anObject startingAt:start |
3706 nextAvailableBytes:count into:anObject startingAt:start |
3679 "read the next count bytes into an object and return the number of |
3707 "read the next count bytes into an object and return the number of |
3680 bytes read or the number of bytes read, if EOF is encountered before, |
3708 bytes read or the number of bytes read, if EOF is encountered before, |
3681 or no more bytes are available for reading (from the pipe/socket). |
3709 or no more bytes are available for reading (from the pipe/socket). |
3682 |
3710 |