Skip to content

Commit

Permalink
compress xmz
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Aug 21, 2024
1 parent 113de5d commit f5ad66b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions xmake/modules/utils/archive/archive_xmz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
Expand All @@ -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

0 comments on commit f5ad66b

Please sign in to comment.