21 lines
714 B
Luau
21 lines
714 B
Luau
-- tools/fixtures/_vpk_encode.luau: run by tools/fixtures/vpk.py under the luau CLI: writes the files of
|
|
-- tests/gen/vpk_src as VPK version 1 and 2 with our encoder and prints "<name>\t<hex>" lines for Python's vpk
|
|
-- package to read back (and verify the version 2 MD5s).
|
|
local Vpk = require("@formats/archive/vpk")
|
|
local Src = require("@tests/gen/vpk_src")
|
|
|
|
local function hex(b: buffer): string
|
|
local s = buffer.tostring(b)
|
|
return (string.gsub(s, ".", function(c: string): string
|
|
return string.format("%02x", string.byte(c))
|
|
end))
|
|
end
|
|
|
|
for _, version in { 1, 2 } do
|
|
local a = Vpk.new(version)
|
|
for _, f in Src do
|
|
a:add(f.name, f.data)
|
|
end
|
|
print("v" .. version .. "\t" .. hex(a:write() :: buffer))
|
|
end
|