OC-misc/tapeloader/mkarchive.lua

25 lines
500 B
Lua
Raw Normal View History

local tArgs = {...}
local function cint(n,l)
local t={}
for i = 0, 7 do
t[i+1] = (n >> (i * 8)) & 0xFF
end
return string.reverse(string.char(table.unpack(t)):sub(1,l))
end
local function genHeader(fname,len)
return string.format("%s%s%s",cint(fname:len(),2),fname,cint(len,2))
end
for k,v in ipairs(tArgs) do
local f = io.open(v,"rb")
if f then
local content = f:read("*a")
f:close()
io.write(genHeader(v,content:len()))
io.write(content)
end
end
io.write(string.char(0):rep(2))