This commit is contained in:
vit9696 2018-10-11 11:39:09 +03:00
parent bc3193420c
commit 14e72cb03a
2 changed files with 14 additions and 5 deletions

View file

@ -23,6 +23,8 @@ USTATUS FfsDumper::dump(const UModelIndex & root, const UString & path, const Du
if (changeDirectory(path)) if (changeDirectory(path))
return U_DIR_ALREADY_EXIST; return U_DIR_ALREADY_EXIST;
currentPath = path;
USTATUS result = recursiveDump(root, path, dumpMode, sectionType, guid); USTATUS result = recursiveDump(root, path, dumpMode, sectionType, guid);
if (result) { if (result) {
return result; return result;
@ -48,7 +50,10 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
if (!changeDirectory(path) && !makeDirectory(path)) if (!changeDirectory(path) && !makeDirectory(path))
return U_DIR_CREATE; return U_DIR_CREATE;
counterHeader = counterBody = counterRaw = counterInfo = 0; if (currentPath != path) {
counterHeader = counterBody = counterRaw = counterInfo = 0;
currentPath = 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) {
@ -88,14 +93,17 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
} }
if (dumpMode == DUMP_FILE && (sectionType == IgnoreSectionType || model->subtype(index) == sectionType)) { if (dumpMode == DUMP_FILE && (sectionType == IgnoreSectionType || model->subtype(index) == sectionType)) {
UModelIndex fileIndex = model->findParentOfType(index, Types::File); UModelIndex fileIndex = index;
if (!fileIndex.isValid()) if (model->type(fileIndex) != Types::File) {
fileIndex = index; fileIndex = model->findParentOfType(index, Types::File);
if (!fileIndex.isValid())
fileIndex = index;
}
UString filename; UString filename;
if (counterRaw == 0) if (counterRaw == 0)
filename = usprintf("%s/file.ffs", path.toLocal8Bit()); filename = usprintf("%s/file.ffs", path.toLocal8Bit());
else else
filename = usprintf("%s/file_%d.bin", path.toLocal8Bit(), counterRaw); filename = usprintf("%s/file_%d.ffs", path.toLocal8Bit(), counterRaw);
counterRaw++; counterRaw++;
std::ofstream file(filename.toLocal8Bit(), std::ofstream::binary); std::ofstream file(filename.toLocal8Bit(), std::ofstream::binary);
if (!file) if (!file)

View file

@ -44,6 +44,7 @@ public:
private: private:
USTATUS recursiveDump(const UModelIndex & root, const UString & path, const DumpMode dumpMode, const UINT8 sectionType, const UString & guid); USTATUS recursiveDump(const UModelIndex & root, const UString & path, const DumpMode dumpMode, const UINT8 sectionType, const UString & guid);
TreeModel* model; TreeModel* model;
UString currentPath;
bool dumped; bool dumped;
int counterHeader, counterBody, counterRaw, counterInfo; int counterHeader, counterBody, counterRaw, counterInfo;
}; };