[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kioslave/file
From:       Vlad Codrea <vladc6 () yahoo ! com>
Date:       2008-05-09 2:59:46
Message-ID: 1210301986.353655.3254.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 805652 by codrea:

Fix translation of the mode from QIODevice to POSIX flag.



 M  +17 -11    file.cpp  


--- trunk/KDE/kdelibs/kioslave/file/file.cpp #805651:805652
@@ -470,17 +470,19 @@
 
     int flags = 0;
     if (mode & QIODevice::ReadOnly) {
-        flags |= O_RDONLY;
+        if (mode & QIODevice::WriteOnly) {
+            flags = O_RDWR | O_CREAT;
+        } else {
+            flags = O_RDONLY;
+        }
+    } else if (mode & QIODevice::WriteOnly) {
+        flags = O_WRONLY | O_CREAT;
     }
-    if (mode & QIODevice::WriteOnly) {
-        flags |= O_WRONLY | O_CREAT;
-    }
+
     if (mode & QIODevice::Append) {
-        flags |= O_WRONLY | O_APPEND;
-    } else if (mode & QIODevice::WriteOnly) {
-        if (!(mode & QIODevice::ReadOnly) || mode & QIODevice::Truncate) {
-            flags |= O_TRUNC;
-        }
+        flags |= O_APPEND;
+    } else if (mode & QIODevice::Truncate) {
+        flags |= O_TRUNC;
     }
 
     int fd = KDE_open( openPath.data(), flags);
@@ -490,8 +492,12 @@
     }
     // Determine the mimetype of the file to be retrieved, and emit it.
     // This is mandatory in all slaves (for KRun/BrowserRun to work).
-    KMimeType::Ptr mt = KMimeType::findByUrl( url, buff.st_mode, true /* local URL */ );
-    emit mimeType( mt->name() );
+    // If we're not opening the file ReadOnly or ReadWrite, don't attempt to
+    // read the file and send the mimetype.
+    if (mode & QIODevice::ReadOnly){
+        KMimeType::Ptr mt = KMimeType::findByUrl( url, buff.st_mode, true /* local URL */ );
+        emit mimeType( mt->name() );
+   }
 
     totalSize( buff.st_size );
     position( 0 );
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic