[erlang-questions] bug in file:pread

Joe Armstrong erlang@REDACTED
Fri Oct 6 14:36:40 CEST 2006


pread(Handle, {eof,-N}, N) appears to be broken or have I misunderstood
something?

/Joe

-module(bug1).

-compile(export_all).

bug() ->
    File = "test.bin",
    file:write_file(File, [<<"123456789">>]),
    {ok, FileHandle} = file:open(File, [binary,raw,read]),
    X1 = file:pread(FileHandle, 1, 2),
    X2 = file:position(FileHandle, {eof,-4}),
    X3 = file:pread(FileHandle, {eof,-4}, 3),
    io:format("X1=~p~nX2=~p~nX3=~p~n~n",[X1,X2,X3]),
    file:close(FileHandle).


1> c(bug1).
{ok,bug1}
2> bug1:bug().
X1={ok,<<"23">>}
X2={ok,5}
X3={error,einval}

ok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061006/04f9b785/attachment.htm>


More information about the erlang-questions mailing list