Fixed: Support QFile write in smaller parts

This commit is contained in:
kervala 2016-10-17 20:45:14 +02:00
parent bedc55578d
commit 9ed1ce8f7c

View file

@ -434,19 +434,29 @@ bool CFilesExtractor::extract7z()
if (!outFile.open(QFile::WriteOnly)) if (!outFile.open(QFile::WriteOnly))
{ {
error = QApplication::tr("Unable to open output file"); error = QApplication::tr("Unable to open output file %1").arg(destPath);
res = SZ_ERROR_FAIL; res = SZ_ERROR_FAIL;
break; break;
} }
size_t processedSize = outFile.write((const char*)(outBuffer + offset), outSizeProcessed); qint64 currentSizeToProcess = outSizeProcessed;
if (processedSize != outSizeProcessed) do
{ {
error = QApplication::tr("Unable to write output file"); qint64 currentProcessedSize = outFile.write((const char*)(outBuffer + offset), currentSizeToProcess);
res = SZ_ERROR_FAIL;
break; // errors only occur when returned size is -1
if (currentProcessedSize < 0)
{
error = QApplication::tr("Unable to write output file %1").arg(destPath);
res = SZ_ERROR_FAIL;
break;
}
offset += currentProcessedSize;
currentSizeToProcess -= currentProcessedSize;
} }
while (currentSizeToProcess > 0);
outFile.close(); outFile.close();