Fix duplicates in UEFIExtract

This commit is contained in:
vit9696 2018-11-11 14:15:11 +03:00
parent 6e481fbb4d
commit aa0ab13411
2 changed files with 29 additions and 18 deletions

View File

@ -19,6 +19,7 @@ USTATUS FfsDumper::dump(const UModelIndex & root, const UString & path, const Du
{
dumped = false;
counterHeader = counterBody = counterRaw = counterInfo = 0;
fileList.clear();
if (changeDirectory(path))
return U_DIR_ALREADY_EXIST;
@ -57,7 +58,9 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
if (dumpMode == DUMP_ALL || model->rowCount(index) == 0) { // Dump if leaf item or dumpAll is true
if (dumpMode == DUMP_ALL || dumpMode == DUMP_CURRENT || dumpMode == DUMP_HEADER) {
if (!model->header(index).isEmpty() && (sectionType == IgnoreSectionType || model->subtype(index) == sectionType)) {
if (!model->header(index).isEmpty() && (sectionType == IgnoreSectionType || model->subtype(index) == sectionType) &&
fileList.count(index) == 0) {
fileList.insert(index);
UString filename;
if (counterHeader == 0)
filename = usprintf("%s/header.bin", path.toLocal8Bit());
@ -75,7 +78,9 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
}
if (dumpMode == DUMP_ALL || dumpMode == DUMP_CURRENT || dumpMode == DUMP_BODY) {
if (!model->body(index).isEmpty() && (sectionType == IgnoreSectionType || model->subtype(index) == sectionType)) {
if (!model->body(index).isEmpty() && (sectionType == IgnoreSectionType || model->subtype(index) == sectionType) &&
fileList.count(index) == 0) {
fileList.insert(index);
UString filename;
if (counterBody == 0)
filename = usprintf("%s/body.bin", path.toLocal8Bit());
@ -99,6 +104,8 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
if (!fileIndex.isValid())
fileIndex = index;
}
if (fileList.count(fileIndex) == 0) {
fileList.insert(fileIndex);
UString filename;
if (counterRaw == 0)
filename = usprintf("%s/file.ffs", path.toLocal8Bit());
@ -118,6 +125,7 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
dumped = true;
}
}
}
// Always dump info unless explicitly prohibited
if ((dumpMode == DUMP_ALL || dumpMode == DUMP_CURRENT || dumpMode == DUMP_INFO)

View File

@ -14,6 +14,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef FFSDUMPER_H
#define FFSDUMPER_H
#include <set>
#include "../common/basetypes.h"
#include "../common/ustring.h"
#include "../common/treemodel.h"
@ -47,5 +49,6 @@ private:
UString currentPath;
bool dumped;
int counterHeader, counterBody, counterRaw, counterInfo;
std::set<UModelIndex> fileList;
};
#endif // FFSDUMPER_H