From fc1f53d8282728b2877ae5ba96eff70e3cbc6bbf Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Tue, 2 Jul 2019 11:01:04 +0800 Subject: xm_io_std_flush --- core/src/xmake/io/file_flush.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/xmake/io/file_flush.c b/core/src/xmake/io/file_flush.c index a750c1b1f..ac43f007d 100644 --- a/core/src/xmake/io/file_flush.c +++ b/core/src/xmake/io/file_flush.c @@ -35,7 +35,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -static tb_bool_t std_flush(xm_io_file* file) { return !fflush(file->std_ref); } +static tb_bool_t xm_io_std_flush(xm_io_file* file) { return !fflush(file->std_ref); } /* * file:flush() @@ -48,11 +48,10 @@ tb_int_t xm_io_file_flush(lua_State* lua) xm_io_file* file = xm_io_getfile(lua); if (xm_io_file_is_closed(file)) xm_io_file_error_closed(lua); - tb_bool_t succeed = xm_io_file_is_file(file) ? tb_file_sync(file->file_ref) : !fflush(file->std_ref); - if (succeed) - { - lua_pushboolean(lua, tb_true); - xm_io_file_success(); - } - xm_io_file_error(lua, "failed to flush file"); + + tb_bool_t succeed = xm_io_file_is_file(file) ? tb_file_sync(file->file_ref) : xm_io_std_flush(file->std_ref); + + if (!succeed) xm_io_file_error(lua, "failed to flush file"); + lua_pushboolean(lua, tb_true); + xm_io_file_success(); } -- cgit v1.3.1