• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Utility Library
 

KDevelop Utility Library

Enumerations | Functions
URLUtil Namespace Reference

Enumerations

enum  SlashesPosition { SLASH_PREFIX = 1, SLASH_SUFFIX = 2 }
 

Functions

TQString filename (const TQString &pathName)
 
TQString directory (const TQString &pathName)
 
TQString relativePath (const KURL &parent, const KURL &child, uint slashPolicy=SLASH_PREFIX)
 
TQString relativePath (const TQString &parent, const TQString &child, uint slashPolicy=SLASH_PREFIX)
 
TQString getRelativePath (const TQString &base, const TQString &dest)
 
TQString relativePathToFile (const TQString &dirUrl, const TQString &fileUrl)
 
TQString upDir (const TQString &path, bool slashSuffix=false)
 
KURL mergeURL (const KURL &source, const KURL &dest, const KURL &child)
 
TQString getExtension (const TQString &path)
 
TQString extractPathNameRelative (const KURL &baseDirUrl, const KURL &url)
 
TQString extractPathNameRelative (const TQString &basePath, const KURL &url)
 
TQString extractPathNameRelative (const TQString &basePath, const TQString &absFilePath)
 
TQString extractPathNameAbsolute (const KURL &url)
 
TQStringList toRelativePaths (const TQString &baseDir, const KURL::List &urls)
 
bool isDirectory (const KURL &url)
 
bool isDirectory (const TQString &absFilePath)
 
void dump (const KURL::List &urls, const TQString &aMessage=TQString())
 
TQString canonicalPath (const TQString &path)
 
TQString envExpand (const TQString &variable)
 

Detailed Description

Utility functions to operate on URLs.

Enumeration Type Documentation

◆ SlashesPosition

enum URLUtil::SlashesPosition

Position of a slash in the URL.

Enumerator
SLASH_PREFIX 

URL has slash as a prefix.

SLASH_SUFFIX 

URL has slash as a suffix.

Definition at line 37 of file urlutil.h.

Function Documentation

◆ canonicalPath()

TQString URLUtil::canonicalPath ( const TQString &  path)

Same as TQDir::canonicalPath in later versions of TQt.

Earlier versions of TQt had this broken, so it's reproduced here. Deprecated, use TQDir::canonicalPath instead.

Definition at line 285 of file urlutil.cpp.

◆ directory()

TQString URLUtil::directory ( const TQString &  pathName)
Returns
The directory part of a path (i.e. everything up to but not including the last slash)
Parameters
pathNameThe absolute path to a directory.

Definition at line 46 of file urlutil.cpp.

◆ dump()

void URLUtil::dump ( const KURL::List &  urls,
const TQString &  aMessage = TQString() 
)

Dumps the list of KURL urls on standard output, eventually printing aMessage if it is not null.

Parameters
urlsURLs to dump.
aMessageMessage to be written onto a stdout.

Definition at line 209 of file urlutil.cpp.

◆ envExpand()

TQString URLUtil::envExpand ( const TQString &  variable)

Performs environment variable expansion on variable.

Parameters
variableThe string with the environment variable to expand.
Returns
The expanded environment variable value. if the variable cannot be expanded, variable itself is returned.

Definition at line 295 of file urlutil.cpp.

◆ extractPathNameAbsolute()

TQString URLUtil::extractPathNameAbsolute ( const KURL &  url)
Parameters
urlThe url to extract the absolute path from.
Returns
The absolute path name referred in url. Look at extractPathNameRelative documentation for an example.

Definition at line 176 of file urlutil.cpp.

◆ extractPathNameRelative() [1/3]

TQString URLUtil::extractPathNameRelative ( const KURL &  baseDirUrl,
const KURL &  url 
)

Given a base directory url in baseDirUrl and the url referring to the sub-directory or file, it will return the path relative to baseDirUrl.

If baseDirUrl == url.path() then it will return ".".

KURL baseUrl, dirUrl;
baseUrl.setPath( "/home/mario/src/tdevelop/" );
dirUrl.setPath( "/home/mario/src/tdevelop/parts/cvs/" );
TQString relPathName = extractDirPathRelative( baseUrl, url ); // == "parts/cvs/"
TQString absPathName = extractDirPathAbsolute( url ); // == "/home/mario/src/tdevelop/parts/cvs/"

Note that if you pass a file name in url (instead of a directory) or the baseUrl is not contained in url then the function will return "" (void string).

Parameters
baseDirUrlBase directory URL.
urlBase directory URL.
Returns
The relative path between url and baseDirUrl.

Definition at line 142 of file urlutil.cpp.

◆ extractPathNameRelative() [2/3]

TQString URLUtil::extractPathNameRelative ( const TQString &  basePath,
const KURL &  url 
)

Same as above.

basePath is TQString.

Definition at line 159 of file urlutil.cpp.

◆ extractPathNameRelative() [3/3]

TQString URLUtil::extractPathNameRelative ( const TQString &  basePath,
const TQString &  absFilePath 
)

Same as above.

Both basePath and absFilePath are TQStrings.

Definition at line 167 of file urlutil.cpp.

◆ filename()

TQString URLUtil::filename ( const TQString &  pathName)
Returns
The filename part of a pathname (i.e. everything past the last slash).
Parameters
pathNameThe absolute path to a file.

Definition at line 39 of file urlutil.cpp.

◆ getExtension()

TQString URLUtil::getExtension ( const TQString &  path)
Returns
The file extension for a filename or path.
Parameters
pathAbsolute or relative path.

Definition at line 134 of file urlutil.cpp.

◆ getRelativePath()

TQString URLUtil::getRelativePath ( const TQString &  base,
const TQString &  dest 
)
Returns
The relative path between a base path and destination path or.
Parameters
baseThe base Path.
destThe destination path.

Definition at line 53 of file urlutil.cpp.

◆ isDirectory() [1/2]

bool URLUtil::isDirectory ( const KURL &  url)
Parameters
urlThe absolute URL.
Returns
true if url is a directory, false otherwise.

Definition at line 195 of file urlutil.cpp.

◆ isDirectory() [2/2]

bool URLUtil::isDirectory ( const TQString &  absFilePath)
Parameters
absFilePathThe absolute path.
Returns
true if url is a directory, false otherwise.

Definition at line 202 of file urlutil.cpp.

◆ mergeURL()

KURL URLUtil::mergeURL ( const KURL &  source,
const KURL &  dest,
const KURL &  child 
)

'Merges' URLs - changes a URL that starts with dest to start with source instead.


Example:
    source is /home/me/
    dest is /home/you/
    child is /home/you/dir1/file1
  returns /home/me/dir1/fil1
Parameters
sourceAn URL of a source.
destAn URL of a destination.
childAn URL to change.
Returns
The result of merge.

Definition at line 113 of file urlutil.cpp.

◆ relativePath() [1/2]

TQString URLUtil::relativePath ( const KURL &  parent,
const KURL &  child,
uint  slashPolicy = SLASH_PREFIX 
)
Returns
The relative path between a parent and child URL, or blank if the specified child is not a child of parent.
Parameters
parentThe parent URL.
childThe child URL.
slashPolicyIf parent and child are equal then the function returns "/" if slashPolicy contains SLASH_PREFIX and otherwise "".
"/" is appended to a result if slashPolicy contains SLASH_SUFFIX.
"/" is prepended to a result if slashPolicy contains SLASH_PREFIX.

Definition at line 85 of file urlutil.cpp.

◆ relativePath() [2/2]

TQString URLUtil::relativePath ( const TQString &  parent,
const TQString &  child,
uint  slashPolicy = SLASH_PREFIX 
)
Returns
The relative path between a parent and child URL, or blank if the specified child is not a child of parent.
Parameters
parentThe parent URL.
childThe child URL.
slashPolicyIf parent and child are equal then the function returns "/" if slashPolicy contains SLASH_PREFIX and otherwise "".
"/" is appended to a result if slashPolicy contains SLASH_SUFFIX.
"/" is prepended to a result if slashPolicy contains SLASH_PREFIX.

Definition at line 99 of file urlutil.cpp.

◆ relativePathToFile()

TQString URLUtil::relativePathToFile ( const TQString &  dirUrl,
const TQString &  fileUrl 
)
Parameters
dirUrlAn URL of a directory.
fileUrlAn URL of a file.
Returns
The relative path between a directory and file. Should never return empty path.
Example:
  dirUrl:  /home/test/src
  fileUrl: /home/test/lib/mylib.cpp
 returns:  ../lib/mylib.cpp

Definition at line 240 of file urlutil.cpp.

◆ toRelativePaths()

TQStringList URLUtil::toRelativePaths ( const TQString &  baseDir,
const KURL::List &  urls 
)
Parameters
baseDirBase directory for relative URLs.
urlsThe list of urls to extract the relative paths from.
Returns
A TQStringList of relative (to baseDir) paths from a list of KURLs in urls.

Definition at line 226 of file urlutil.cpp.

◆ upDir()

TQString URLUtil::upDir ( const TQString &  path,
bool  slashSuffix = false 
)
Parameters
pathA path (absolute or relative).
slashSuffixif true then "/" is appended to a path.
Returns
The path 'up one level' - the opposite of what filename returns.

Definition at line 105 of file urlutil.cpp.

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Utility Library by doxygen 1.8.13
This website is maintained by Timothy Pearson.