summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-08-21 23:54:09 +0800
committerruki <[email protected]>2024-08-21 23:54:09 +0800
commitf5ad66b003ca864dfdc047dc75c4f0a016654f5d (patch)
treeeaaf7b6652a71c911af992191192dc7cee41ccc7
parent113de5d5d6d32eaff57c502dd55ac7bc6645a8ab (diff)
compress xmz
-rw-r--r--xmake/modules/utils/archive/archive_xmz.lua23
1 files changed, 21 insertions, 2 deletions
diff --git a/xmake/modules/utils/archive/archive_xmz.lua b/xmake/modules/utils/archive/archive_xmz.lua
index d9cf427c6..96c83490b 100644
--- a/xmake/modules/utils/archive/archive_xmz.lua
+++ b/xmake/modules/utils/archive/archive_xmz.lua
@@ -20,6 +20,23 @@
-- imports
import("core.base.option")
+import("core.compress.lz4")
+
+-- archive files
+function _archive_files(archivefile, inputfiles, opt)
+ local outputfile = io.open(archivefile, "wb")
+ for _, inputfile in ipairs(inputfiles) do
+ outputfile:write(inputfile)
+ local data = io.readfile(inputfile, {encoding = "binary"})
+ outputfile:write(data)
+ end
+ outputfile:close()
+end
+
+-- compress file
+function _compress_file(archivefile, outputfile, opt)
+ lz4.compress_file(archivefile, outputfile)
+end
-- archive file
--
@@ -39,6 +56,8 @@ function main(archivefile, inputfiles, opt)
end
inputfiles = files
- print("archivefile", archivefile)
- print("inputfiles", inputfiles)
+ local archivefile_tmp = os.tmpfile({ramdisk = false})
+ _archive_files(archivefile_tmp, inputfiles, opt)
+ _compress_file(archivefile_tmp, archivefile, opt)
+ os.tryrm(archivefile_tmp)
end