summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-10 23:53:02 +0800
committerruki <[email protected]>2022-05-10 23:53:02 +0800
commitb202e67144520e99dd748b0cac66c78520ffd617 (patch)
treecbe6b9842caeb621d8184e55b7838273aa71892c
parentbd25e040e4318f8b1eb60c045196fac7962154b6 (diff)
improve lz4 errors
-rw-r--r--xmake/core/compress/lz4.lua20
1 files changed, 9 insertions, 11 deletions
diff --git a/xmake/core/compress/lz4.lua b/xmake/core/compress/lz4.lua
index 26c06562b..e228494ce 100644
--- a/xmake/core/compress/lz4.lua
+++ b/xmake/core/compress/lz4.lua
@@ -76,22 +76,20 @@ end
-- compress file data
function lz4.compress_file(srcpath, dstpath, opt)
- return lz4._compress_file(srcpath, dstpath)
-
- --[[
- local data, errors = io.readfile(srcpath, {encoding = "binary"})
- if data then
- data, errors = lz4.compress(data, opt)
- if data then
- return io.writefile(dstpath, data, {encoding = "binary"})
- end
+ local ok, errors = lz4._compress_file(tostring(srcpath), tostring(dstpath))
+ if not ok then
+ errors = string.format("compress file %s failed!", srcpath, errors or os.strerror() or "unknown")
end
- return false, errors or "compress failed"]]
+ return ok, errors
end
-- decompress file data
function lz4.decompress_file(srcpath, dstpath, opt)
- return lz4._decompress_file(srcpath, dstpath)
+ local ok, errors = lz4._decompress_file(tostring(srcpath), tostring(dstpath))
+ if not ok then
+ errors = string.format("compress file %s failed!", srcpath, errors or os.strerror() or "unknown")
+ end
+ return ok, errors
end
-- compress block data