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

List:       kde-commits
Subject:    KDE/kdelibs/kioslave/file
From:       David Faure <faure () kde ! org>
Date:       2009-11-13 21:28:35
Message-ID: 1258147715.303554.28657.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1048732 by dfaure:

Fix compilation on systems without d_type/DT_DIR, like Solaris
BUG: 191544


 M  +15 -1     file_unix.cpp  


--- trunk/KDE/kdelibs/kioslave/file/file_unix.cpp #1048731:1048732
@@ -333,6 +333,9 @@
     //kDebug(7101) << "========= LIST " << url << "details=" << details << " =========";
     UDSEntry entry;
 
+#ifndef HAVE_DIRENT_D_TYPE
+    KDE_struct_stat st;
+#endif
     // Don't make this a QStringList. The locale file name we get here
     // should be passed intact to createUDSEntry to avoid problems with
     // files where QFile::encodeName(QFile::decodeName(a)) != a.
@@ -344,9 +347,20 @@
         while ( ( ep = KDE_readdir( dp ) ) != 0 ) {
             entry.clear();
             entry.insert(KIO::UDSEntry::UDS_NAME, QFile::decodeName(ep->d_name));
+#ifdef HAVE_DIRENT_D_TYPE
             entry.insert(KIO::UDSEntry::UDS_FILE_TYPE,
                          (ep->d_type & DT_DIR) ? S_IFDIR : S_IFREG );
-            if (ep->d_type & DT_LNK) {
+            const bool isSymLink = (ep->d_type & DT_LNK);
+#else
+            // oops, no fast way, we need to stat (e.g. on Solaris)
+            if (KDE_lstat(ep->d_name, &st) == -1) {
+                continue; // how can stat fail?
+            }
+            entry.insert(KIO::UDSEntry::UDS_FILE_TYPE,
+                          (S_ISDIR(st.st_mode)) ? S_IFDIR : S_IFREG );
+            const bool isSymLink = S_ISLNK(st.st_mode);
+#endif
+            if (isSymLink) {
                 // for symlinks obey the UDSEntry contract and provide UDS_LINK_DEST
                 // even if we don't know the link dest (and DeleteJob doesn't care...)
                 entry.insert(KIO::UDSEntry::UDS_LINK_DEST, QLatin1String("Dummy Link Target"));
[prev in list] [next in list] [prev in thread] [next in thread] 

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