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

List:       kde-commits
Subject:    kdelibs/kdecore
From:       Jaroslaw Staniek <js () iidea ! pl>
Date:       2005-02-15 13:56:53
Message-ID: 20050215135653.477D11D1A7 () office ! kde ! org
[Download RAW message or body]

CVS commit by staniek: 

Win32 paths-related fixes (and generally for non-latin1 filesystems)
(reviewed)

1. CWD is cashed within KCmdLineArgs, but getcwd() returns a path with
backslashes: win32_slashify() is called to fix it to a form which is
expected by KCmdLineArgs.

2. KCmdLineArgs::makeURL() handling absolute paths fixed

3. KURL: internal cleanpath() function: handling absolute paths fixed 

A note from Waldo Bastian:

"Use QFile::decodeName instead of QString::fromLocal8Bit. 
QString::fromLocal8Bit only differs from QFile::decodeName() if 
$KDE_UTF8_FILENAMES is set, and in that case it is really hard to tell which 
of the two should be used. KProcess uses QFile::decodeName to encode command 
line arguments, so we better use that for decoding as well. This issue will 
become even less relevant over time since utf8 is becoming more popular as 
locale in which case setting $KDE_UTF8_FILENAMES makes no difference
anyway."


  M +12 -3     kcmdlineargs.cpp   1.100
  M +1 -1      kurl.cpp   1.288


--- kdelibs/kdecore/kcmdlineargs.cpp  #1.99:1.100
@@ -31,4 +31,5 @@
 #endif
 
+#include <qdir.h>
 #include <qfile.h>
 #include <qasciidict.h>
@@ -49,4 +50,8 @@
 #endif
 
+#ifdef Q_WS_WIN
+#include <win32_utils.h>
+#endif
+
 template class QAsciiDict<QCString>;
 template class QPtrList<KCmdLineArgs>;
@@ -180,4 +185,7 @@ KCmdLineArgs::init(int _argc, char **_ar
    mCwd = mCwdd.setObject(mCwd, new char [PATH_MAX+1], true);
    getcwd(mCwd, PATH_MAX);
+#ifdef Q_WS_WIN
+   win32_slashify(mCwd, PATH_MAX);
+#endif
    if (!noKApp)
       KApplication::addCmdLineOptions();
@@ -1227,8 +1235,9 @@ KCmdLineArgs::url(int n) const
 KURL KCmdLineArgs::makeURL( const char *urlArg )
 {
-   if (*urlArg == '/')
+   QString _urlArg = QFile::decodeName( urlArg );
+   if (!QDir::isRelativePath(_urlArg))
    {
       KURL result;
-      result.setPath(QFile::decodeName( urlArg));
+      result.setPath(_urlArg);
       return result; // Absolute path.
    }
@@ -1238,5 +1247,5 @@ KURL KCmdLineArgs::makeURL( const char *
 
    KURL result;
-   result.setPath( cwd()+"/"+QFile::decodeName( urlArg ));
+   result.setPath( cwd()+"/"+_urlArg );
    result.cleanPath();
    return result;  // Relative path

--- kdelibs/kdecore/kurl.cpp  #1.287:1.288
@@ -317,5 +317,5 @@ static QString cleanpath(const QString &
   if (_path.isEmpty()) return QString::null;
 
-  if (_path[0] != '/')
+  if (QDir::isRelativePath(_path))
      return _path; // Don't mangle mailto-style URLs
 


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

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