From: Lukas Hrazky Date: Sun, 15 Aug 2010 12:13:09 +0000 (+0200) Subject: fixed error handling on sequential file check X-Git-Tag: v0.3.0~7 X-Git-Url: https://vcs.maemo.org/git/?p=case;a=commitdiff_plain;h=88f4a205b9c4053903f1bb5ea619a537e4f8a282 fixed error handling on sequential file check Signed-off-by: Lukas Hrazky --- diff --git a/src/fileoperator.cpp b/src/fileoperator.cpp index 8e6335a..422f90b 100644 --- a/src/fileoperator.cpp +++ b/src/fileoperator.cpp @@ -46,7 +46,12 @@ response = FileOperator::IGNORE; \ } else { \ char buf[255]; \ - char *realBuf = strerror_r(errno, buf, 255); \ + char *realBuf = buf; \ + if (errno == 255) { \ + strcpy(buf, tr("File is sequential").toStdString().c_str()); \ + } else { \ + realBuf = strerror_r(errno, buf, 255); \ + } \ emit showErrorPrompt(this, promptString + " " + realBuf + ".", fileName, errno); \ waitOnCond(); \ } @@ -628,7 +633,7 @@ void FileManipulatorThread::copy(const QFileInfo &file) { return; } - SPECIAL_COPY_ERROR_PROMPT(engine.isSequential(), tr("Cannot copy sequential file %1."), path) + SPECIAL_COPY_ERROR_PROMPT(checkSequentialFile(engine), tr("Cannot copy file %1."), path) if (newFile.exists() && newFile.isDir()) { SPECIAL_COPY_ERROR_PROMPT(!remove(newPath), @@ -774,6 +779,17 @@ void FileManipulatorThread::waitOnCond() { } +bool FileManipulatorThread::checkSequentialFile(const QFSFileEngine &engine) { + errno = 0; + if (engine.isSequential()) { + if (!errno) errno = 255; + return true; + } + + return false; +} + + void FileManipulatorThread::wake() { startTime += time(0) - waitTime; waitCond.wakeAll(); diff --git a/src/fileoperator.h b/src/fileoperator.h index b73e45a..2bf253e 100644 --- a/src/fileoperator.h +++ b/src/fileoperator.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -118,6 +119,8 @@ protected: void waitOnCond(); + bool checkSequentialFile(const QFSFileEngine &engine); + QWaitCondition waitCond; // files to process by the operation