diff options
| author | ruki <[email protected]> | 2016-03-16 10:41:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-03-16 10:41:57 +0800 |
| commit | 566d33d6be83884239cce7df0655e60ec00bd836 (patch) | |
| tree | 79409e657888768fe28fa2ad3af0a52cb7d355ee /xmake/core/base | |
| parent | 5862427be483f6747d88d3a79121e2a4f2a27670 (diff) | |
load project
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/io.lua | 25 |
1 files changed, 25 insertions, 0 deletions
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) |
