Skip to content

Commit 5621bbe

Browse files
author
LocalIdentity
committed
Fix #9402 merge
Forgot to fix conflicts before merging
1 parent fdf6813 commit 5621bbe

File tree

2 files changed

+31
-180
lines changed

2 files changed

+31
-180
lines changed

src/Export/Classes/GGPKData.lua

Lines changed: 31 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -63,49 +63,44 @@ function GGPKClass:ExtractFilesWithBun(fileListStr, useRegex)
6363
os.execute(cmd)
6464
end
6565

66+
-- Use manifest files to avoid command line limit and reduce cmd calls
67+
function GGPKClass:ExtractFilesWithBunFromTable(fileTable, useRegex)
68+
local useRegex = useRegex or false
69+
local manifest = self.oozPath .. "extract_list.txt"
70+
local f = assert(io.open(manifest, "w"))
71+
for _, fname in ipairs(fileTable) do
72+
f:write(string.lower(fname), "\n")
73+
end
74+
f:close()
75+
local cmd = 'cd "' .. self.oozPath .. '" && bun_extract_file.exe extract-files ' .. (useRegex and '--regex "' or '"') .. self.path .. '" . < "' .. manifest .. '"'
76+
ConPrintf(cmd)
77+
os.execute(cmd)
78+
os.remove(manifest)
79+
end
80+
6681
function GGPKClass:ExtractFiles(reExport)
6782
if reExport then
6883
local datList, txtList, otList, itList = self:GetNeededFiles()
69-
local sweetSpotCharacter = 6000
70-
local fileList = ''
84+
local datFiles = {}
7185
for _, fname in ipairs(datList) do
72-
if USE_DAT64 then
73-
fileList = fileList .. '"' .. fname .. 'c64" '
74-
else
75-
fileList = fileList .. '"' .. fname .. '" '
76-
end
77-
78-
if fileList:len() > sweetSpotCharacter then
79-
self:ExtractFilesWithBun(fileList)
80-
fileList = ''
81-
end
86+
datFiles[#datFiles + 1] = fname .. "c64"
8287
end
83-
84-
for _, fname in ipairs(otList) do
85-
self:ExtractFilesWithBun('"' .. fname .. '"', true)
86-
end
87-
88-
for _, fname in ipairs(txtList) do
89-
fileList = fileList .. '"' .. fname .. '" '
9088

91-
if fileList:len() > sweetSpotCharacter then
92-
self:ExtractFilesWithBun(fileList)
93-
fileList = ''
94-
end
89+
-- non-regex chunk: dat files + txtList + itList
90+
for i = 1, #txtList do
91+
datFiles[#datFiles + 1] = itList[i]
9592
end
96-
97-
for _, fname in ipairs(itList) do
98-
fileList = fileList .. '"' .. fname .. '" '
99-
100-
if fileList:len() > sweetSpotCharacter then
101-
self:ExtractFilesWithBun(fileList)
102-
fileList = ''
103-
end
93+
for i = 1, #itList do
94+
datFiles[#datFiles + 1] = itList[i]
10495
end
96+
self:ExtractFilesWithBunFromTable(datFiles, false)
10597

106-
if (fileList:len() > 0) then
107-
self:ExtractFilesWithBun(fileList)
98+
-- regex chunk: otList
99+
local regexFiles = {}
100+
for i = 1, #otList do
101+
regexFiles[#regexFiles + 1] = otList[i]
108102
end
103+
self:ExtractFilesWithBunFromTable(regexFiles, true)
109104
end
110105

111106
-- Overwrite Enums
@@ -117,39 +112,16 @@ end
117112

118113
function GGPKClass:ExtractList(listToExtract, cache, useRegex)
119114
useRegex = useRegex or false
120-
local sweetSpotCharacter = 6000
121115
printf("Extracting ...")
122-
local fileList = ''
116+
local fileTable = {}
123117
for _, fname in ipairs(listToExtract) do
124118
-- we are going to validate if the file is already extracted in this session
125119
if not cache[fname] then
126120
cache[fname] = true
127-
fileList = fileList .. '"' .. string.lower(fname) .. '" '
128-
129-
if fileList:len() > sweetSpotCharacter then
130-
self:ExtractFilesWithBun(fileList, useRegex)
131-
fileList = ''
132-
end
121+
fileTable[#fileTable + 1] = fname
133122
end
134123
end
135-
136-
if fileList:len() > 0 then
137-
self:ExtractFilesWithBun(fileList, useRegex)
138-
fileList = ''
139-
end
140-
end
141-
142-
function GGPKClass:AddDatFiles()
143-
local datFiles = scanDir(self.oozPath .. "Data\\", '%w+%.dat$')
144-
for _, f in ipairs(datFiles) do
145-
local record = { }
146-
record.name = f
147-
local rawFile = io.open(self.oozPath .. "Data\\" .. f, 'rb')
148-
record.data = rawFile:read("*all")
149-
rawFile:close()
150-
--ConPrintf("FILENAME: %s", fname)
151-
t_insert(self.dat, record)
152-
end
124+
self:ExtractFilesWithBunFromTable(fileTable, useRegex)
153125
end
154126

155127
function GGPKClass:AddDat64Files()

src/Export/Classes/GGPKData.lua.rej

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)