From 10cc2da7638bc5656e2573cd1ab84279b989fad6 Mon Sep 17 00:00:00 2001 From: Lukas Hrazky Date: Sun, 22 Aug 2010 01:00:52 +0200 Subject: [PATCH] pause in the middle of copying a file w/o reset Signed-off-by: Lukas Hrazky --- src/operationthread.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/operationthread.cpp b/src/operationthread.cpp index d0cf7e1..873ff72 100644 --- a/src/operationthread.cpp +++ b/src/operationthread.cpp @@ -302,7 +302,7 @@ void OperationThread::copy(const QFileInfo &file) { engine.seek(0); fileValue = 0; - ERROR_PROMPT(!newEngine.open(QIODevice::WriteOnly | QIODevice::Truncate), + ERROR_PROMPT(!newEngine.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Unbuffered), tr("Error writing file %1."), newPath) if (abort || response == IGNORE) { @@ -321,13 +321,9 @@ void OperationThread::copy(const QFileInfo &file) { qint64 bytes; while ((bytes = engine.read(block, sizeof(block))) > 0) { - if (bytes == -1 || bytes != newEngine.write(block, bytes)) { - if (bytes == -1) { - SHOW_ERROR_PROMPT(tr("Error while reading from file %1."), path); - } else { - SHOW_ERROR_PROMPT(tr("Error while writing to file %1."), newPath); - } - + if (bytes == -1) { + SHOW_ERROR_PROMPT(tr("Error while reading from file %1."), path); + if (!abort) { if (response == IGNORE) { updateProgress(fileSizeMap[path] - fileValue); @@ -339,10 +335,30 @@ void OperationThread::copy(const QFileInfo &file) { } error = true; break; + } else { + qint64 written = 0; + char *blockPointer = block; + while (bytes != (written = newEngine.write(blockPointer, bytes))) { + SHOW_ERROR_PROMPT(tr("Error while writing to file %1."), newPath); + + if (response == IGNORE) { + updateProgress(fileSizeMap[path] - fileValue); + removeExcludeFiles.insert(path); + ignore = true; + } + + if (abort || ignore) break; + + if (written == -1) written = 0; + bytes -= written; + blockPointer += written; + + PAUSE(); + } } PAUSE(); - if (abort) break; + if (abort || ignore) break; updateProgress(1); } -- 1.7.9.5