diff options
| author | OpportunityLiu <[email protected]> | 2019-07-02 11:01:04 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-07-02 11:01:04 +0800 |
| commit | fc1f53d8282728b2877ae5ba96eff70e3cbc6bbf (patch) | |
| tree | 1141b8b6865895cad6160b75a9487133f804861d /core/src | |
| parent | 10194ed2bc005211feba0c6d54924782b69f7fc6 (diff) | |
xm_io_std_flush
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/io/file_flush.c | 15 |
1 files 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(); } |
