diff options
| -rw-r--r-- | xmake/core/compress/lz4.lua | 20 |
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 |
