OC-misc/partition/partition.lua

24 lines
444 B
Lua
Raw Permalink Normal View History

2020-02-19 18:39:48 +11:00
local partition = {}
local eformat = "c20c4>I4>I4"
function partition.parse(s)
local rt = {}
for i = 1, s:len(), 32 do
local n, t, start, length = string.unpack(eformat, s, i)
n = n:gsub("\0", "")
if n ~= "" then
rt[#rt+1] = {n,t,start,length}
2020-02-19 18:39:48 +11:00
end
end
return rt
2020-02-19 18:39:48 +11:00
end
function partition.generate(pt)
local ps = ""
for k,v in ipairs(pt) do
ps = ps .. string.pack(eformat, table.unpack(v))
2020-02-19 18:39:48 +11:00
end
return ps
2020-02-19 18:39:48 +11:00
end
return partition