summaryrefslogtreecommitdiff
path: root/xmake/core/base/io.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-04 16:30:37 +0800
committerruki <[email protected]>2016-03-04 16:30:37 +0800
commitf81e2102271015548d991db6fe420c9942de7a69 (patch)
tree325c0714a953de7f9137d6b84a38ee96f39308a3 /xmake/core/base/io.lua
parent1f2256373162935addf69ce870369adb1b17dc5f (diff)
impl global action
Diffstat (limited to 'xmake/core/base/io.lua')
-rw-r--r--xmake/core/base/io.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua
index 14b6e37a3..3b04b9fdd 100644
--- a/xmake/core/base/io.lua
+++ b/xmake/core/base/io.lua
@@ -139,9 +139,18 @@ end
-- save object the the given filepath
function io.save(filepath, object)
+
+ -- check
+ assert(filepath and object)
+
+ -- ensure directory
+ local dir = path.directory(filepath)
+ if not os.isdir(dir) then
+ os.mkdir(dir)
+ end
-- open the file
- local file = io.openmk(filepath)
+ local file = io.open(filepath, "w")
if not file then
-- error
return false, string.format("open %s failed!", filepath)
@@ -164,6 +173,9 @@ end
-- load object from the given file
function io.load(filepath)
+ -- check
+ assert(filepath)
+
-- open the file
local file = io.open(filepath, "r")
if not file then