diff options
Diffstat (limited to 'lib/util/urlutil.cpp')
-rw-r--r-- | lib/util/urlutil.cpp | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/lib/util/urlutil.cpp b/lib/util/urlutil.cpp index fb451769..849cc555 100644 --- a/lib/util/urlutil.cpp +++ b/lib/util/urlutil.cpp @@ -18,10 +18,10 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <qstringlist.h> +#include <tqstringlist.h> -#include <qdir.h> -#include <qfileinfo.h> +#include <tqdir.h> +#include <tqfileinfo.h> #include <kdebug.h> #include <unistd.h> @@ -36,28 +36,28 @@ // Namespace URLUtil /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::filename(const QString & name) { +TQString URLUtil::filename(const TQString & name) { int slashPos = name.findRev("/"); return slashPos<0 ? name : name.mid(slashPos+1); } /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::directory(const QString & name) { +TQString URLUtil::directory(const TQString & name) { int slashPos = name.findRev("/"); - return slashPos<0 ? QString("") : name.left(slashPos); + return slashPos<0 ? TQString("") : name.left(slashPos); } /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::getRelativePath(const QString& basepath, const QString& destpath) +TQString URLUtil::getRelativePath(const TQString& basepath, const TQString& destpath) { - QString relpath = "."; - if (!QFile::exists(basepath) || - !QFile::exists(destpath)) + TQString relpath = "."; + if (!TQFile::exists(basepath) || + !TQFile::exists(destpath)) return ""; - QStringList basedirs = QStringList::split(QString( QChar( QDir::separator() ) ),basepath); - QStringList destdirs = QStringList::split(QString( QChar( QDir::separator() ) ),destpath); + TQStringList basedirs = TQStringList::split(TQString( TQChar( TQDir::separator() ) ),basepath); + TQStringList destdirs = TQStringList::split(TQString( TQChar( TQDir::separator() ) ),destpath); int maxCompare=0; if (basedirs.count()>=destdirs.count()) @@ -72,23 +72,23 @@ QString URLUtil::getRelativePath(const QString& basepath, const QString& destpat lastCommonDir=i; } for (uint i=0;i<basedirs.count()-(lastCommonDir+1); i++) - relpath += QString( QChar( QDir::separator() ) )+QString(".."); + relpath += TQString( TQChar( TQDir::separator() ) )+TQString(".."); for (int i=0; i<lastCommonDir+1; i++) destdirs.pop_front(); if (destdirs.count()) - relpath += QString( QChar( QDir::separator() ) )+destdirs.join( QChar( QDir::separator() ) ); - return QDir::cleanDirPath(relpath); + relpath += TQString( TQChar( TQDir::separator() ) )+destdirs.join( TQChar( TQDir::separator() ) ); + return TQDir::cleanDirPath(relpath); } /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::relativePath(const KURL & parent, const KURL & child, uint slashPolicy) { +TQString URLUtil::relativePath(const KURL & parent, const KURL & child, uint slashPolicy) { bool slashPrefix = slashPolicy & SLASH_PREFIX; bool slashSuffix = slashPolicy & SLASH_SUFFIX; if (parent.equals(child,true)) - return slashPrefix ? QString("/") : QString(""); + return slashPrefix ? TQString("/") : TQString(""); - if (!parent.isParentOf(child)) return QString(); + if (!parent.isParentOf(child)) return TQString(); int a=slashPrefix ? -1 : 1; int b=slashSuffix ? 1 : -1; return child.path(b).mid(parent.path(a).length()); @@ -96,15 +96,15 @@ QString URLUtil::relativePath(const KURL & parent, const KURL & child, uint slas /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::relativePath(const QString & parent, const QString & child, uint slashPolicy) { +TQString URLUtil::relativePath(const TQString & parent, const TQString & child, uint slashPolicy) { return relativePath(KURL(parent), KURL(child), slashPolicy); } /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::upDir(const QString & path, bool slashSuffix) { +TQString URLUtil::upDir(const TQString & path, bool slashSuffix) { int slashPos = path.findRev("/"); - if (slashPos<1) return QString::null; + if (slashPos<1) return TQString::null; return path.mid(0,slashPos+ (slashSuffix ? 1 : 0) ); } @@ -122,41 +122,41 @@ KURL URLUtil::mergeURL(const KURL & source, const KURL & dest, const KURL & chil if (dest.equals(child,true)) return source; // calculate - QString childUrlStr = child.url(-1); - QString destStemStr = dest.url(1); - QString sourceStemStr = source.url(1); + TQString childUrlStr = child.url(-1); + TQString destStemStr = dest.url(1); + TQString sourceStemStr = source.url(1); return KURL(sourceStemStr.append( childUrlStr.mid( destStemStr.length() ) ) ); } /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::getExtension(const QString & path) { +TQString URLUtil::getExtension(const TQString & path) { int dotPos = path.findRev('.'); - if (dotPos<0) return QString(""); + if (dotPos<0) return TQString(""); return path.mid(dotPos+1); } /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::extractPathNameRelative(const KURL &baseDirUrl, const KURL &url ) +TQString URLUtil::extractPathNameRelative(const KURL &baseDirUrl, const KURL &url ) { - QString absBase = extractPathNameAbsolute( baseDirUrl ), + TQString absBase = extractPathNameAbsolute( baseDirUrl ), absRef = extractPathNameAbsolute( url ); int i = absRef.find( absBase, 0, true ); if (i == -1) - return QString(); + return TQString(); if (absRef == absBase) - return QString( "." ); + return TQString( "." ); else - return absRef.replace( 0, absBase.length(), QString() ); + return absRef.replace( 0, absBase.length(), TQString() ); } /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::extractPathNameRelative(const QString &basePath, const KURL &url ) +TQString URLUtil::extractPathNameRelative(const TQString &basePath, const KURL &url ) { KURL baseDirUrl = KURL::fromPathOrURL( basePath ); return extractPathNameRelative( baseDirUrl, url ); @@ -164,7 +164,7 @@ QString URLUtil::extractPathNameRelative(const QString &basePath, const KURL &ur /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::extractPathNameRelative(const QString &basePath, const QString &absFilePath ) +TQString URLUtil::extractPathNameRelative(const TQString &basePath, const TQString &absFilePath ) { KURL baseDirUrl = KURL::fromPathOrURL( basePath ), fileUrl = KURL::fromPathOrURL( absFilePath ); @@ -173,7 +173,7 @@ QString URLUtil::extractPathNameRelative(const QString &basePath, const QString /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::extractPathNameAbsolute( const KURL &url ) +TQString URLUtil::extractPathNameAbsolute( const KURL &url ) { if (isDirectory( url )) return url.path( +1 ); // with trailing "/" if none is present @@ -182,9 +182,9 @@ QString URLUtil::extractPathNameAbsolute( const KURL &url ) // Ok, this is an over-tight pre-condition on "url" since I hope nobody will never // stress this function with absurd cases ... but who knows? /* - QString path = url.path(); - QFileInfo fi( path ); // Argh: QFileInfo is back ;)) - return ( fi.exists()? path : QString() ); + TQString path = url.path(); + TQFileInfo fi( path ); // Argh: TQFileInfo is back ;)) + return ( fi.exists()? path : TQString() ); */ return url.path(); } @@ -199,14 +199,14 @@ bool URLUtil::isDirectory( const KURL &url ) /////////////////////////////////////////////////////////////////////////////// -bool URLUtil::isDirectory( const QString &absFilePath ) +bool URLUtil::isDirectory( const TQString &absFilePath ) { - return QDir( absFilePath ).exists(); + return TQDir( absFilePath ).exists(); } /////////////////////////////////////////////////////////////////////////////// -void URLUtil::dump( const KURL::List &urls, const QString &aMessage ) +void URLUtil::dump( const KURL::List &urls, const TQString &aMessage ) { if (!aMessage.isNull()) { @@ -223,9 +223,9 @@ void URLUtil::dump( const KURL::List &urls, const QString &aMessage ) /////////////////////////////////////////////////////////////////////////////// -QStringList URLUtil::toRelativePaths( const QString &baseDir, const KURL::List &urls) +TQStringList URLUtil::toRelativePaths( const TQString &baseDir, const KURL::List &urls) { - QStringList paths; + TQStringList paths; for (size_t i=0; i<urls.count(); ++i) { @@ -237,25 +237,25 @@ QStringList URLUtil::toRelativePaths( const QString &baseDir, const KURL::List & /////////////////////////////////////////////////////////////////////////////// -QString URLUtil::relativePathToFile( const QString & dirUrl, const QString & fileUrl ) +TQString URLUtil::relativePathToFile( const TQString & dirUrl, const TQString & fileUrl ) { if (dirUrl.isEmpty() || (dirUrl == "/")) return fileUrl; - QStringList dir = QStringList::split("/", dirUrl, false); - QStringList file = QStringList::split("/", fileUrl, false); + TQStringList dir = TQStringList::split("/", dirUrl, false); + TQStringList file = TQStringList::split("/", fileUrl, false); - QString resFileName = file.last(); + TQString resFileName = file.last(); file.remove(file.last()); uint i = 0; while ( (i < dir.count()) && (i < (file.count())) && (dir[i] == file[i]) ) i++; - QString result_up; - QString result_down; - QString currDir; - QString currFile; + TQString result_up; + TQString result_down; + TQString currDir; + TQString currFile; do { i >= dir.count() ? currDir = "" : currDir = dir[i]; @@ -282,9 +282,9 @@ QString URLUtil::relativePathToFile( const QString & dirUrl, const QString & fil /////////////////////////////////////////////////////////////////////////////// //TODO: remove for KDE4 -QString URLUtil::canonicalPath( const QString & path ) +TQString URLUtil::canonicalPath( const TQString & path ) { - QDir dir(path); + TQDir dir(path); return dir.canonicalPath(); } @@ -292,7 +292,7 @@ QString URLUtil::canonicalPath( const QString & path ) //written by "Dawit A." <adawit@kde.org> //borrowed from his patch to KShell -QString URLUtil::envExpand ( const QString& str ) +TQString URLUtil::envExpand ( const TQString& str ) { uint len = str.length(); @@ -303,11 +303,11 @@ QString URLUtil::envExpand ( const QString& str ) if (pos < 0) pos = len; - char* ret = getenv( QConstString(str.unicode()+1, pos-1).string().local8Bit().data() ); + char* ret = getenv( TQConstString(str.unicode()+1, pos-1).string().local8Bit().data() ); if (ret) { - QString expandedStr ( QFile::decodeName( ret ) ); + TQString expandedStr ( TQFile::decodeName( ret ) ); if (pos < (int)len) expandedStr += str.mid(pos); return expandedStr; |