JuliaLang/julia — pull request #3878 by stevengj (2013-07-30 04:27:34+00:00)
Title: new readbytes and readbytes! functions

This pull request expands the functionality of the `readbytes` functions that we already have into two new functions (inspired by the functionality in Python's [RawIOBase](http://docs.python.org/2/library/io.html#i-o-base-classes) class):
```
readbytes!(stream, buffer::Vector{Uint8}, nb=length(buffer))
readbytes(stream, nb=typemax(Int))
```
The `readbytes!` function reads up to `nb` bytes into `buffer` (growing it as needed), returning the number of bytes read. The `readbytes` function reads up to `nb` bytes and returns a new Vector{Uint8} buffer containing the bytes read.

(Incidentally, we had two different implementations of `readall(s::IO)`, one replacing the other; I kept the one that uses `readbytes`.)