mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 16:08:23 +08:00
Fix duplicates in UEFIExtract
This commit is contained in:
parent
6e481fbb4d
commit
aa0ab13411
@ -19,6 +19,7 @@ USTATUS FfsDumper::dump(const UModelIndex & root, const UString & path, const Du
|
|||||||
{
|
{
|
||||||
dumped = false;
|
dumped = false;
|
||||||
counterHeader = counterBody = counterRaw = counterInfo = 0;
|
counterHeader = counterBody = counterRaw = counterInfo = 0;
|
||||||
|
fileList.clear();
|
||||||
|
|
||||||
if (changeDirectory(path))
|
if (changeDirectory(path))
|
||||||
return U_DIR_ALREADY_EXIST;
|
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 || model->rowCount(index) == 0) { // Dump if leaf item or dumpAll is true
|
||||||
if (dumpMode == DUMP_ALL || dumpMode == DUMP_CURRENT || dumpMode == DUMP_HEADER) {
|
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;
|
UString filename;
|
||||||
if (counterHeader == 0)
|
if (counterHeader == 0)
|
||||||
filename = usprintf("%s/header.bin", path.toLocal8Bit());
|
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 (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;
|
UString filename;
|
||||||
if (counterBody == 0)
|
if (counterBody == 0)
|
||||||
filename = usprintf("%s/body.bin", path.toLocal8Bit());
|
filename = usprintf("%s/body.bin", path.toLocal8Bit());
|
||||||
@ -99,23 +104,26 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
|
|||||||
if (!fileIndex.isValid())
|
if (!fileIndex.isValid())
|
||||||
fileIndex = index;
|
fileIndex = index;
|
||||||
}
|
}
|
||||||
UString filename;
|
if (fileList.count(fileIndex) == 0) {
|
||||||
if (counterRaw == 0)
|
fileList.insert(fileIndex);
|
||||||
filename = usprintf("%s/file.ffs", path.toLocal8Bit());
|
UString filename;
|
||||||
else
|
if (counterRaw == 0)
|
||||||
filename = usprintf("%s/file_%d.ffs", path.toLocal8Bit(), counterRaw);
|
filename = usprintf("%s/file.ffs", path.toLocal8Bit());
|
||||||
counterRaw++;
|
else
|
||||||
std::ofstream file(filename.toLocal8Bit(), std::ofstream::binary);
|
filename = usprintf("%s/file_%d.ffs", path.toLocal8Bit(), counterRaw);
|
||||||
if (!file)
|
counterRaw++;
|
||||||
return U_FILE_OPEN;
|
std::ofstream file(filename.toLocal8Bit(), std::ofstream::binary);
|
||||||
const UByteArray &headerData = model->header(fileIndex);
|
if (!file)
|
||||||
const UByteArray &bodyData = model->body(fileIndex);
|
return U_FILE_OPEN;
|
||||||
const UByteArray &tailData = model->tail(fileIndex);
|
const UByteArray &headerData = model->header(fileIndex);
|
||||||
file.write(headerData.constData(), headerData.size());
|
const UByteArray &bodyData = model->body(fileIndex);
|
||||||
file.write(bodyData.constData(), bodyData.size());
|
const UByteArray &tailData = model->tail(fileIndex);
|
||||||
file.write(tailData.constData(), tailData.size());
|
file.write(headerData.constData(), headerData.size());
|
||||||
|
file.write(bodyData.constData(), bodyData.size());
|
||||||
|
file.write(tailData.constData(), tailData.size());
|
||||||
|
|
||||||
dumped = true;
|
dumped = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#ifndef FFSDUMPER_H
|
#ifndef FFSDUMPER_H
|
||||||
#define FFSDUMPER_H
|
#define FFSDUMPER_H
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "../common/basetypes.h"
|
#include "../common/basetypes.h"
|
||||||
#include "../common/ustring.h"
|
#include "../common/ustring.h"
|
||||||
#include "../common/treemodel.h"
|
#include "../common/treemodel.h"
|
||||||
@ -47,5 +49,6 @@ private:
|
|||||||
UString currentPath;
|
UString currentPath;
|
||||||
bool dumped;
|
bool dumped;
|
||||||
int counterHeader, counterBody, counterRaw, counterInfo;
|
int counterHeader, counterBody, counterRaw, counterInfo;
|
||||||
|
std::set<UModelIndex> fileList;
|
||||||
};
|
};
|
||||||
#endif // FFSDUMPER_H
|
#endif // FFSDUMPER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user