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;
}
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;
}
}
}