Fix #152, caused by multiple body match

This commit is contained in:
vit9696 2018-11-24 22:48:41 +03:00
parent e1c0b08fc0
commit d9325c22fe

View File

@ -109,28 +109,31 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
fileIndex = index; fileIndex = index;
} }
fileList.insert(fileIndex); // We may select parent file during ffs extraction.
if (fileList.count(fileIndex) == 0) {
fileList.insert(fileIndex);
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.ffs", 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)
return U_FILE_OPEN; return U_FILE_OPEN;
const UByteArray &headerData = model->header(fileIndex); const UByteArray &headerData = model->header(fileIndex);
const UByteArray &bodyData = model->body(fileIndex); const UByteArray &bodyData = model->body(fileIndex);
const UByteArray &tailData = model->tail(fileIndex); const UByteArray &tailData = model->tail(fileIndex);
file.write(headerData.constData(), headerData.size()); file.write(headerData.constData(), headerData.size());
file.write(bodyData.constData(), bodyData.size()); file.write(bodyData.constData(), bodyData.size());
file.write(tailData.constData(), tailData.size()); file.write(tailData.constData(), tailData.size());
dumped = true; dumped = true;
}
} }
} }