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

List:       kde-windows
Subject:    'lightweight' QDir::isAbsolutePath replacement ?
From:       Ralf Habacker <ralf.habacker () freenet ! de>
Date:       2008-03-06 12:42:08
Message-ID: 47CFE6A0.1080603 () freenet ! de
[Download RAW message or body]

Hi,

there are several places in the kde code which needs a check if a path 
is absolute. On unix this is mainly done by using  
QString::startsWith('/'), which does not work as expected on windows.

The only static method Qt provides to handle this platform independent 
is QDir::isAbsolutePath(). Unfortunally this method seems to be very 
time expensive because it creates a temporary QDir instance.
A second Qt provided way is QFileInfo::isAbsolute(), although this 
method is non static and requires to create a QFileInfo instance before 
which blows up code unnecessarily.

the third option is to check this directly
    QString path = .... ;
    if ( (path.startsWith(QLatin1Char('/')) || (path[0].isLetter() && 
path[1] == QLatin1Char(':')) )
       // handle absolute Path

an additional imaginable way would be to add kde only static functions 
for this purpose in the KDE namespace. For example
    KDE::isAbsolutePath(const QString &path)
    KDE::isAbsolutePath(const QByteArray &path)
    KDE::isAbsolutePath(const KUrl &url)
    ....

with an implementation similar to:

    return (path.startsWith(QLatin1Char('/')) || (path.[0].isLetter() && 
path[1] == QLatin1Char(':')) ) ;


The question is which way the prefered is ?

Ralf




_______________________________________________
Kde-windows mailing list
Kde-windows@kde.org
https://mail.kde.org/mailman/listinfo/kde-windows
[prev in list] [next in list] [prev in thread] [next in thread] 

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