diff --git a/UEFIExtract/ffsdumper.cpp b/UEFIExtract/ffsdumper.cpp index f522727..9b6096b 100644 --- a/UEFIExtract/ffsdumper.cpp +++ b/UEFIExtract/ffsdumper.cpp @@ -109,28 +109,31 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path fileIndex = index; } - fileList.insert(fileIndex); + // We may select parent file during ffs extraction. + if (fileList.count(fileIndex) == 0) { + fileList.insert(fileIndex); - UString filename; - if (counterRaw == 0) - filename = usprintf("%s/file.ffs", path.toLocal8Bit()); - else - filename = usprintf("%s/file_%d.ffs", path.toLocal8Bit(), counterRaw); - counterRaw++; + UString filename; + if (counterRaw == 0) + filename = usprintf("%s/file.ffs", path.toLocal8Bit()); + else + filename = usprintf("%s/file_%d.ffs", path.toLocal8Bit(), counterRaw); + counterRaw++; - std::ofstream file(filename.toLocal8Bit(), std::ofstream::binary); - if (!file) - return U_FILE_OPEN; + std::ofstream file(filename.toLocal8Bit(), std::ofstream::binary); + if (!file) + return U_FILE_OPEN; - const UByteArray &headerData = model->header(fileIndex); - const UByteArray &bodyData = model->body(fileIndex); - const UByteArray &tailData = model->tail(fileIndex); + const UByteArray &headerData = model->header(fileIndex); + const UByteArray &bodyData = model->body(fileIndex); + const UByteArray &tailData = model->tail(fileIndex); - file.write(headerData.constData(), headerData.size()); - file.write(bodyData.constData(), bodyData.size()); - 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; + } } }