MCPcopy Create free account
hub / github.com/Segs/Segs / extractAllFiles

Function extractAllFiles

Projects/CoX/Utilities/MapViewer/src/PiggTools.cpp:178–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178bool extractAllFiles(PiggFile &pigg,const QString &tgt_path)
179{
180 QFile src_fl(pigg.fname);
181 if(!src_fl.open(QFile::ReadOnly))
182 {
183 qWarning() << "failed to open source file" << pigg.fname;
184 return false;
185 }
186 const QDir curdir(tgt_path);
187 for(const PiggInternalHeader & ih : pigg.headers)
188 {
189 const QString target_fname=pigg.strings_table.data_parts[ih.name_id];
190 if(qApp)
191 qApp->processEvents();
192 else
193 qDebug().noquote() << "Extracting"<<target_fname;
194 src_fl.seek(ih.offset);
195 bool was_packed = ih.packed_size!=0;
196 QByteArray src_data = src_fl.read(was_packed ? ih.packed_size : ih.size);
197 const QFileInfo fi(target_fname);
198 if(!curdir.exists(fi.path()))
199 curdir.mkpath(fi.path());
200 if(was_packed) {
201 QByteArray actual_data = uncompr_zip(src_data,ih.size);
202 src_data = actual_data;
203 }
204 if(!saveFile(curdir.filePath(target_fname),src_data))
205 return false;
206 }
207 return true;
208}
209} // namespace
210
211bool unpackPiggFile(const QString &filename,const QString &target_path)

Callers 1

unpackPiggFileFunction · 0.70

Calls 4

uncompr_zipFunction · 0.70
saveFileFunction · 0.70
openMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected