Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readbytes!(s::IOStream, b::Array{Uint8}, nb=length(b)) does not respect nb argument #5653

Closed
lendle opened this issue Feb 3, 2014 · 0 comments

Comments

@lendle
Copy link
Contributor

lendle commented Feb 3, 2014

When reading from an IOStream, readbytes! reads length(b) bytes regardless of the nb.

Everything worked as expected when reading from an IOBuffer, so here is an example with a test file.

julia> f = open("testfile", "w")
       write(f, collect(0x01:0x0a))
       close(f);

julia> f = open("testfile")
       one = zeros(Uint8, 8)
       readbytes!(f, one, 3) #should be 3
8

julia> one #only first 3 bytes should be nonzero
8-element Array{Uint8,1}:
 0x01
 0x02
 0x03
 0x04
 0x05
 0x06
 0x07
 0x08


julia> seekstart(f); #reset f

julia> two = zeros(Uint8, 8)
       two[1:3] = readbytes(f, 3)
       two #this is what I expect "one" to be
8-element Array{Uint8,1}:
 0x01
 0x02
 0x03
 0x00
 0x00
 0x00
 0x00
 0x00
JeffBezanson added a commit that referenced this issue Feb 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant