增加List处理功能

This commit is contained in:
2025-09-04 14:30:09 +08:00
parent 80390e48a7
commit 4235742d87
13 changed files with 615 additions and 82 deletions
+40 -64
View File
@@ -1,76 +1,52 @@
--print npk file list to file
--[[
npkFileName(string): npk file path name(utf8)
listFileName(string): list output path name(utf8)
keyName(boolean): print key name
npkName(boolean): print npk file name
npkBase(boolean): print npk base dir name
fileSize(boolean): print file size
fileCRC(boolean): print file crc
fileOffset(boolean): print file offset
return(boolean): is success
local M = require("dump_npk_list")
local ret = M.dump_npk_file_list(
{
"D:\\WeGameApps\\地下城与勇士:创新世纪\\ImagePacks2\\sprite_character_archer_effect_air.NPK",
"D:\\WeGameApps\\地下城与勇士:创新世纪\\ImagePacks2\\sprite_interface2_event_20160927_national_day_firework.NPK"
},
"d:\\output.txt",
false, false, false, false, false
)
--]]
local M={}
function M.dump_npk_file_list(npkFileName, listFileName, npkBase, npkName, keyName, fileOffset, fileSize, fileCRC)
local npk = createNPKFile();
function M.dump_npk_file_list(npkFileNames, listFileName, npkBase, npkName, fileOffset, fileSize, fileCRC)
local finalList = createEmptyFileList()
local ret = npk:openPakFile(npkFileName)
if(not ret) then
return false
for i,npkFileName in pairs(npkFileNames) do
local npk = createNPKFile();
local ret = npk:openPakFile(npkFileName)
if(not ret) then
return false
end
local fileList = npk:generateFullInfoList()
if(not fileList)then
return false
end
ret = finalList:mergeOtherListInto(fileList, true)
if(not ret) then
return false
end
destroyFileList(fileList)
npk:closePakFile()
destroyNPKFile(npk)
end
listOutputFile = io.open(listFileName, "w")
fileList = npk:generateFullInfoList();
counts = fileList:getFileCounts()
local flags = 0
if fileCRC then flags = 1 end
if fileSize then flags = flags + bit.lshift(1, 1) end
if fileOffset then flags = flags + bit.lshift(1, 2) end
if npkName then flags = flags + bit.lshift(1, 3) end
if npkBase then flags = flags + bit.lshift(1, 4) end
for i=0, counts-1, 1 do
local fileInfo = fileList:getFileItem(i)
outputLine=""
if(npkBase) then
if(#outputLine>0) then outputLine = outputLine .. "|" end
outputLine = outputLine .. fileInfo:npkBase();
end
if(npkName) then
if(#outputLine>0) then outputLine = outputLine .. "|" end
outputLine = outputLine .. fileInfo:npkName();
end
if(keyName) then
if(#outputLine>0) then outputLine = outputLine .. "|" end
outputLine = outputLine .. fileInfo:keyName();
end
if(fileOffset) then
if(#outputLine>0) then outputLine = outputLine .. "|" end
outputLine = outputLine .. tostring(fileInfo.fileOffset);
end
if(fileSize) then
if(#outputLine>0) then outputLine = outputLine .. "|" end
outputLine = outputLine .. tostring(fileInfo.fileSize);
end
if(fileCRC) then
if(#outputLine>0) then outputLine = outputLine .. "|" end
outputLine = outputLine .. tostring(fileInfo.fileCRC);
end
if(#outputLine>0) then
listOutputFile:write(outputLine .. "\n")
end
end
listOutputFile:close()
destroyFileList(fileList)
npk:closePakFile()
destroyNPKFile(npk)
finalList:dumpToLocalFile(listFileName, flags)
destroyFileList(finalList)
return true
end
+7
View File
@@ -4,6 +4,13 @@ npkFileName The path to the NPK archive file to be extracted.
outputPath The path to the output directory where files will be extracted.
return true if extraction succeeds; false otherwise.
--]]
--[[
local M = require("extrace_npk_file")
local ret = M.extract_npk_files("D:\\WeGameApps\\地下城与勇士:创新世纪\\ImagePacks2\\sprite_character_archer_effect_air.NPK",
"D:\\_temp\\output"
)
--]]
local M={}
function M.extract_npk_files(npkFileName, outputPath)
local npk = createNPKFile();