summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-08-20 17:53:05 +0800
committerruki <[email protected]>2019-08-20 17:55:19 +0800
commitf0edb8798d3c425249792c735eec7655c5eb2b62 (patch)
tree7e58f9b477c6fa7844c9f6cef8260b453295aeb7
parentb4aaf6ec3aa7d2d9d6f21f267a46869d25275d16 (diff)
improve file close
-rw-r--r--core/src/xmake/io/file_close.c3
-rw-r--r--xmake/modules/private/tools/vstool.lua8
2 files changed, 5 insertions, 6 deletions
diff --git a/core/src/xmake/io/file_close.c b/core/src/xmake/io/file_close.c
index 5c7d5c75d..6b3efdd98 100644
--- a/core/src/xmake/io/file_close.c
+++ b/core/src/xmake/io/file_close.c
@@ -66,8 +66,7 @@ tb_int_t xm_io_file_close(lua_State* lua)
#endif
// close file
- if (!tb_stream_clos(file->file_ref))
- xm_io_file_return_error(lua, "failed to close file");
+ tb_stream_clos(file->file_ref);
file->file_ref = tb_null;
// exit fstream
diff --git a/xmake/modules/private/tools/vstool.lua b/xmake/modules/private/tools/vstool.lua
index ba0ec8edc..83539d301 100644
--- a/xmake/modules/private/tools/vstool.lua
+++ b/xmake/modules/private/tools/vstool.lua
@@ -43,8 +43,8 @@ function runv(program, argv, opt)
if ok ~= 0 then
-- read errors
- local outdata = io.readfile(outpath)
- local errdata = io.readfile(errpath)
+ local outdata = os.isfile(outpath) and io.readfile(outpath) or nil
+ local errdata = os.isfile(errpath) and io.readfile(errpath) or nil
local errors = errdata or ""
if #errors:trim() == 0 then
errors = outdata or ""
@@ -92,8 +92,8 @@ function iorunv(program, argv, opt)
-- get output and error data
outfile:close()
- local outdata = io.readfile(outpath)
- local errdata = io.readfile(errpath)
+ local outdata = os.isfile(outpath) and io.readfile(outpath) or nil
+ local errdata = os.isfile(errpath) and io.readfile(errpath) or nil
-- remove the temporary output and error file
os.tryrm(outpath)