fixed error handling on sequential file check
authorLukas Hrazky <lukkash@email.cz>
Sun, 15 Aug 2010 12:13:09 +0000 (14:13 +0200)
committerLukas Hrazky <lukkash@email.cz>
Sun, 15 Aug 2010 12:13:09 +0000 (14:13 +0200)
Signed-off-by: Lukas Hrazky <lukkash@email.cz>

src/fileoperator.cpp
src/fileoperator.h

index 8e6335a..422f90b 100644 (file)
         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();
index b73e45a..2bf253e 100644 (file)
@@ -24,6 +24,7 @@
 #include <QMutex>
 #include <QWaitCondition>
 #include <QDir>
+#include <QFSFileEngine>
 #include <QMap>
 #include <QSet>
 
@@ -118,6 +119,8 @@ protected:
 
     void waitOnCond();
 
+    bool checkSequentialFile(const QFSFileEngine &engine);
+
     QWaitCondition waitCond;
 
     // files to process by the operation