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
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
-
pathName The 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
-
urls URLs to dump. aMessage Message 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
-
variable The 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
-
url The 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 ".".
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
-
baseDirUrl Base directory URL. url Base directory URL.
- Returns
- The relative path between
url
andbaseDirUrl
.
Definition at line 142 of file urlutil.cpp.
◆ extractPathNameRelative() [2/3]
TQString URLUtil::extractPathNameRelative | ( | const TQString & | basePath, |
const KURL & | url | ||
) |
◆ 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
-
pathName The 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
-
path Absolute 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
-
base The base Path. dest The destination path.
Definition at line 53 of file urlutil.cpp.
◆ isDirectory() [1/2]
bool URLUtil::isDirectory | ( | const KURL & | url | ) |
- Parameters
-
url The 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
-
absFilePath The 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
-
source An URL of a source. dest An URL of a destination. child An 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
-
parent The parent URL. child The child URL. slashPolicy If 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
-
parent The parent URL. child The child URL. slashPolicy If 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
-
dirUrl An URL of a directory. fileUrl An 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
-
baseDir Base directory for relative URLs. urls The list of urls to extract the relative paths from.
- Returns
- A TQStringList of relative (to
baseDir
) paths from a list of KURLs inurls
.
Definition at line 226 of file urlutil.cpp.
◆ upDir()
TQString URLUtil::upDir | ( | const TQString & | path, |
bool | slashSuffix = false |
||
) |
- Parameters
-
path A path (absolute or relative). slashSuffix if 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.