From a57a0eb0ce545965dee6e4fc6e55a08746d9da6c Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 20:45:14 +0200 Subject: [PATCH] Fixed: Support QFile write in smaller parts --HG-- branch : develop --- .../ryzom_installer/src/filesextractor.cpp | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp b/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp index 7139df77d..e038d93bc 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filesextractor.cpp @@ -434,19 +434,29 @@ bool CFilesExtractor::extract7z() 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; break; } - size_t processedSize = outFile.write((const char*)(outBuffer + offset), outSizeProcessed); - - if (processedSize != outSizeProcessed) + qint64 currentSizeToProcess = outSizeProcessed; + + do { - error = QApplication::tr("Unable to write output file"); - res = SZ_ERROR_FAIL; - break; + qint64 currentProcessedSize = outFile.write((const char*)(outBuffer + offset), currentSizeToProcess); + + // 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();