aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/file_io_server.erl
diff options
context:
space:
mode:
authorsoranoba <[email protected]>2015-03-14 15:03:49 +0900
committersoranoba <[email protected]>2015-03-14 15:03:49 +0900
commitfa2b944f13fc85bdee593e1896c61ca2e3a7def9 (patch)
tree7596c3a25db1d2e51f74b469c60476c7493f0c6a /lib/kernel/src/file_io_server.erl
parent425668272206a0f2e4b383aef0e2364e35046686 (diff)
downloadotp-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.erl7
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