113 lines
2.6 KiB
Plaintext
Executable File
113 lines
2.6 KiB
Plaintext
Executable File
--
|
|
-- File:: validate_inplace_psos.rbs
|
|
-- Description:: Checks PSO files within a subtree to see which ones are not in-place loadable.
|
|
--
|
|
-- Author:: Russ Schaaf
|
|
-- Date:: 24 Oct 2012
|
|
--
|
|
|
|
function usageError()
|
|
error("Usage: ragebuilder validate_inplace_psos.rbs -platform <PLATFORM> -path <PATH>")
|
|
end
|
|
|
|
platform = get_param("platform")
|
|
if platform == nil then
|
|
usageError()
|
|
end
|
|
|
|
set_platform(platform)
|
|
|
|
path = get_param("path")
|
|
if path == nil then
|
|
usageError()
|
|
end
|
|
|
|
function walk_tree(path, eachFileCb)
|
|
local files = find_files(path .. "\\*.*")
|
|
for key, value in files do
|
|
eachFileCb(path .. "\\" .. value)
|
|
end
|
|
|
|
-- recurse in all directories
|
|
local dirs = find_dirs(path)
|
|
for key, value in dirs do
|
|
local dir = path .. "\\" .. value
|
|
walk_tree(dir, eachFileCb)
|
|
end
|
|
end
|
|
|
|
|
|
function processFile(path)
|
|
if string.find(path, "%.rpf$") or string.find(path, "%.zip$") then
|
|
processPack(path)
|
|
elseif string.find(path, "%..map$") or string.find(path, "%..typ$") or string.find(path, "%..mt$") or string.find(path, "%.cut$") then
|
|
processPso(path)
|
|
end
|
|
end
|
|
|
|
g_PackfileStack = {}
|
|
g_PackDepth = 0
|
|
function processPack(path, isRpf)
|
|
g_PackDepth = g_PackDepth + 1
|
|
table.insert(g_PackfileStack, path)
|
|
local mountPointName = "packfile" .. g_PackDepth .. ":"
|
|
|
|
local isRpf = string.find(path, "%.rpf$")
|
|
|
|
if isRpf then
|
|
mount_pack(path, mountPointName)
|
|
else
|
|
mount_zip(path, mountPointName)
|
|
end
|
|
|
|
walk_tree(mountPointName, processFile)
|
|
|
|
if isRpf then
|
|
unmount_pack(path)
|
|
else
|
|
unmount_zip(path)
|
|
end
|
|
|
|
table.remove(g_PackfileStack)
|
|
g_PackDepth = g_PackDepth - 1
|
|
end
|
|
|
|
g_PsoFiles = {}
|
|
|
|
function processPso(path)
|
|
print("Checking PSO file " .. path)
|
|
|
|
-- need to extract the PSO file first
|
|
memFile = extract_file_to_memory(path)
|
|
|
|
local packfile = g_PackfileStack[table.getn(g_PackfileStack)] or ''
|
|
local fullname = packfile .. ' :: ' .. string.gsub(path, "packfile%d*:\\", "")
|
|
|
|
local result = is_pso_inplace_loadable(memFile, true)
|
|
if result < 0 then
|
|
print("Error opening file " .. path .. " (not a PSO?)")
|
|
else
|
|
g_PsoFiles[fullname] = {path=path, packfile=packfile, result=result}
|
|
end
|
|
|
|
release_file_from_memory(memFile)
|
|
end
|
|
|
|
walk_tree(path, processFile)
|
|
|
|
print()
|
|
print("-----------------------------------------------------------------------------------")
|
|
print("These files can't be loaded in-place (see above for specifics)")
|
|
notInPlace = {}
|
|
for key,value in g_PsoFiles do
|
|
if value.result == 0 then
|
|
table.insert(notInPlace,key)
|
|
end
|
|
end
|
|
table.sort(notInPlace)
|
|
for idx,val in notInPlace do
|
|
print(" " .. val)
|
|
end
|
|
|
|
|