diff options
author | soranoba <[email protected]> | 2015-03-14 15:03:49 +0900 |
---|---|---|
committer | soranoba <[email protected]> | 2015-03-14 15:03:49 +0900 |
commit | fa2b944f13fc85bdee593e1896c61ca2e3a7def9 (patch) | |
tree | 7596c3a25db1d2e51f74b469c60476c7493f0c6a /lib/kernel/src/file_io_server.erl | |
parent | 425668272206a0f2e4b383aef0e2364e35046686 (diff) | |
download | otp-fa2b944f13fc85bdee593e1896c61ca2e3a7def9.tar.gz otp-fa2b944f13fc85bdee593e1896c61ca2e3a7def9.tar.bz2 otp-fa2b944f13fc85bdee593e1896c61ca2e3a7def9.zip |
Fix file:position (not raw mode)
When it called the "file:position", it subtract the size that was
read into the buffer, and returns the value.
However, it has been discarded buffer and correct position is lost,
if "file:postion" returns error.
Diffstat (limited to 'lib/kernel/src/file_io_server.erl')
-rw-r--r-- | lib/kernel/src/file_io_server.erl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/kernel/src/file_io_server.erl b/lib/kernel/src/file_io_server.erl index 0e9ff5bc0f..d0ad43afbf 100644 --- a/lib/kernel/src/file_io_server.erl +++ b/lib/kernel/src/file_io_server.erl @@ -256,7 +256,12 @@ file_request(close, {stop,normal,?PRIM_FILE:close(Handle),State#state{buf= <<>>}}; file_request({position,At}, #state{handle=Handle,buf=Buf}=State) -> - std_reply(position(Handle, At, Buf), State); + case position(Handle, At, Buf) of + {error, _Reason}=Reply -> + {error,Reply,State}; + Reply -> + {reply,Reply,State#state{buf= <<>>}} + end; file_request(truncate, #state{handle=Handle}=State) -> case ?PRIM_FILE:truncate(Handle) of |