JuliaLang/julia — pull request #6483 by rened (2014-04-09 17:36:08+00:00)
Title: fix #6400

Apparently OSX simply does not read / write blocks larger than 2^32-1. Strangely I could not find any references for this behavior. See https://gist.github.com/rened/10294680 for an analysis.

The fix is to only read / write MAXSIZE bytes in one go, the _os_read_all and _os_write_all function will iterate until everything got read / written.

All julia unit tests pass, and this checks the large size reads/writes:

```jl
filename = "/tmp/bigfile"
for N = 30:34
nbytes = 2^N
println("N: $N, $nbytes bytes")
data = Array(Uint8, nbytes)
open(filename, "w") do s
wrote = write(s, data)
if wrote!=nbytes
error("wrote only $wrote of $nbytes bytes")
end
println(" write worked!")
end
input = zero(data)
open(filename, "r") do s
read!(s, input)
assert(input==data)
println(" read worked!")
end
end
```