From 566d33d6be83884239cce7df0655e60ec00bd836 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 16 Mar 2016 10:41:57 +0800 Subject: load project --- xmake/core/base/io.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'xmake/core/base') diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua index 3b04b9fdd..71c6cc5b8 100644 --- a/xmake/core/base/io.lua +++ b/xmake/core/base/io.lua @@ -27,6 +27,9 @@ local io = io or {} local path = require("base/path") local utils = require("base/utils") +-- save original open +io._open = io._open or io.open + -- save object with the level function io._save_with_level(file, object, level) @@ -137,6 +140,28 @@ function io.writall(filepath, data) return true end +-- replace the original open interface +function io.open(filepath, mode) + + -- check + assert(filepath) + + -- write file? + if mode == "w" then + + -- get the file directory + local dir = path.directory(filepath) + + -- ensure the file directory + if not os.isdir(dir) then + os.mkdir(dir) + end + end + + -- open it + return io._open(filepath, mode) +end + -- save object the the given filepath function io.save(filepath, object) -- cgit v1.3.1