fixed error handling on sequential file check
[case] / src / fileoperator.cpp
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();