summaryrefslogtreecommitdiff
path: root/xmake/core/sandbox/modules/io.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-17 11:17:11 +0800
committerruki <[email protected]>2016-03-17 11:17:11 +0800
commit2b233ade0aba7cb061d7b576357a462910c4b62f (patch)
treee81f198ef7b2e84ecb736dbaa3fe9057308b0187 /xmake/core/sandbox/modules/io.lua
parent713413a6f962704fdb5078a38b32c8637eca3d7a (diff)
make config.h
Diffstat (limited to 'xmake/core/sandbox/modules/io.lua')
-rw-r--r--xmake/core/sandbox/modules/io.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/xmake/core/sandbox/modules/io.lua b/xmake/core/sandbox/modules/io.lua
index 5c7d0fc27..ad10d8a95 100644
--- a/xmake/core/sandbox/modules/io.lua
+++ b/xmake/core/sandbox/modules/io.lua
@@ -48,6 +48,25 @@ function sandbox_io.gsub(filepath, pattern, replace)
return data, count
end
+-- open file
+function sandbox_io.open(filepath, mode)
+
+ -- check
+ assert(filepath)
+
+ -- format it first
+ filepath = vformat(filepath)
+
+ -- open it
+ local file, errors = io.open(filepath, mode)
+ if not file then
+ raise(errors)
+ end
+
+ -- ok?
+ return file
+end
+
-- load object from the given file
function sandbox_io.load(filepath)