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

List:       kde-commits
Subject:    kdevelop/lib/util
From:       Julian Rockey <linux () jrockey ! com>
Date:       2003-08-16 21:23:01
[Download RAW message or body]

CVS commit by jrockey: 

canonicalPath for use for all QT version


  M +23 -0     urlutil.cpp   1.10
  M +8 -0      urlutil.h   1.8


--- kdevelop/lib/util/urlutil.cpp  #1.9:1.10
@@ -18,4 +18,7 @@
 #include <qfileinfo.h>
 #include <kdebug.h>
+#include <qdir.h>
+
+#include <unistd.h>
 
 #include "urlutil.h"
@@ -190,2 +193,22 @@ QString URLUtil::relativePathToFile( con
   return result_up + result_down + resFileName;
 }
+
+// code from qt-3.1.2 version of QDir::canonicalPath()
+
+QString URLUtil::canonicalPath( const QString & path )
+{
+    QString r;
+    char cur[PATH_MAX+1];
+    if ( ::getcwd( cur, PATH_MAX ) )
+    {
+        char tmp[PATH_MAX+1];
+        if( ::realpath( QFile::encodeName( path ), tmp ) )
+        {
+            r = QFile::decodeName( tmp );
+        }
+        //always make sure we go back to the current dir
+        ::chdir( cur );
+    }
+    return r;
+}
+

--- kdevelop/lib/util/urlutil.h  #1.7:1.8
@@ -103,4 +103,12 @@ namespace URLUtil
   */
   void dump( const KURL::List &urls, const QString &aMessage = QString::null );
+
+  /**
+   * Same as QDir::canonicalPath in later versions of QT. Earlier versions of QT
+   * had this broken, so it's reproduced here.
+   */
+  QString canonicalPath( const QString & path );
+
+
 };
 


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

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