summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-10 22:21:23 +0800
committerruki <[email protected]>2019-07-10 08:08:23 +0800
commitd08ce22527736b59691d26810405961483d68c29 (patch)
treec791070f8a690e221ecb241010bccdb4d1f5a1cd
parent635a192a0422ba5fcfcf69ef28e25297d649b708 (diff)
read binary lua file
-rw-r--r--xmake/core/_xmake_main.lua2
-rw-r--r--xmake/core/base/io.lua6
2 files changed, 4 insertions, 4 deletions
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua
index 809c58715..e0f5ab6f9 100644
--- a/xmake/core/_xmake_main.lua
+++ b/xmake/core/_xmake_main.lua
@@ -49,7 +49,7 @@ function loadfile(filepath)
end
-- load script data from file
- local data, rerrors = io.readfile(filepath)
+ local data, rerrors = io.readfile(filepath, {encoding = "binary"})
if not data then
return nil, rerrors
end
diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua
index 59d1b5d6a..114a7a00c 100644
--- a/xmake/core/base/io.lua
+++ b/xmake/core/base/io.lua
@@ -174,7 +174,7 @@ function io.open(filepath, mode, opt)
opt = opt or {}
-- open it
- local handle = io._open(path.translate(filepath), mode .. (opt.encoding or ""))
+ local handle = io._open(filepath, mode .. (opt.encoding or ""))
if not handle then
return nil, string.format("failed to open %s", filepath)
end
@@ -203,7 +203,7 @@ function io.save(filepath, object, opt)
end
-- open the file
- local file = io.open(filepath, "w", opt)
+ local file = io.open(filepath, "wb", opt)
if not file then
-- error
return false, string.format("open %s failed!", filepath)
@@ -233,7 +233,7 @@ function io.load(filepath, opt)
opt = opt or {}
-- open the file
- local file = io.open(filepath, "r", opt)
+ local file = io.open(filepath, "rb", opt)
if not file then
-- error
return nil, string.format("open %s failed!", filepath)