Skip to content

Commit f5ad66b

Browse files
committed
compress xmz
1 parent 113de5d commit f5ad66b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

xmake/modules/utils/archive/archive_xmz.lua

+21-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@
2020

2121
-- imports
2222
import("core.base.option")
23+
import("core.compress.lz4")
24+
25+
-- archive files
26+
function _archive_files(archivefile, inputfiles, opt)
27+
local outputfile = io.open(archivefile, "wb")
28+
for _, inputfile in ipairs(inputfiles) do
29+
outputfile:write(inputfile)
30+
local data = io.readfile(inputfile, {encoding = "binary"})
31+
outputfile:write(data)
32+
end
33+
outputfile:close()
34+
end
35+
36+
-- compress file
37+
function _compress_file(archivefile, outputfile, opt)
38+
lz4.compress_file(archivefile, outputfile)
39+
end
2340

2441
-- archive file
2542
--
@@ -39,6 +56,8 @@ function main(archivefile, inputfiles, opt)
3956
end
4057
inputfiles = files
4158

42-
print("archivefile", archivefile)
43-
print("inputfiles", inputfiles)
59+
local archivefile_tmp = os.tmpfile({ramdisk = false})
60+
_archive_files(archivefile_tmp, inputfiles, opt)
61+
_compress_file(archivefile_tmp, archivefile, opt)
62+
os.tryrm(archivefile_tmp)
4463
end

0 commit comments

Comments
 (0)