Quark  0.1
PathUtils Class Reference

A collection of utility functions for manipulating file paths. More...

#include <PathUtils.h++>

Static Public Member Functions

static QString filenameForPath (const QString &path)
 Returns the filename portion of a path. More...
 
static QString basenameForPath (const QString &path)
 Returns the basename portion of a path. More...
 
static QString extensionForPath (const QString &path)
 Returns the file extension portion of a path. More...
 
static QString directoryForPath (const QString &path)
 Returns the direction portion of the path. More...
 
static QString joinPath (const QString &dir, const QString &filename)
 Combines a directory with a filename, inserting a file separator if the directory does not end with one. More...
 
static QString relativePath (const QString &path, const QString &prefix)
 Returns the portion of a path that is relative to the given prefix path, or an empty string if the path does not begin with that prefix path. More...
 
static QString parentDirectoryForPath (const QString &path)
 Returns the parent directory of a given path. More...
 
static void removeLastPathComponent (QString &path)
 Removes the last path component from the given path, that is, everything after and including the last file separator in the path. More...
 

Detailed Description

A collection of utility functions for manipulating file paths.

Author
Mark Lindner

Member Function Documentation

◆ basenameForPath()

static QString basenameForPath ( const QString &  path)
static

Returns the basename portion of a path.

The basename is the filename excluding any characters after the first '.' character. For example, the basename for '/var/log/logs.tar.gz' is 'logs'.

◆ directoryForPath()

static QString directoryForPath ( const QString &  path)
static

Returns the direction portion of the path.

The directory is everything up to but not including the last file separator in the path, or an empty string if the path contains no file separators at all.

◆ extensionForPath()

static QString extensionForPath ( const QString &  path)
static

Returns the file extension portion of a path.

The file extension is the portion of the filename following the first '.' character. For example, the extension for '/var/log/logs.tar.gz' is 'tar.gz'.

◆ filenameForPath()

static QString filenameForPath ( const QString &  path)
static

Returns the filename portion of a path.

The filename is everything after the last file separator in the path, and as such, may be an empty string.

◆ joinPath()

static QString joinPath ( const QString &  dir,
const QString &  filename 
)
static

Combines a directory with a filename, inserting a file separator if the directory does not end with one.

◆ parentDirectoryForPath()

static QString parentDirectoryForPath ( const QString &  path)
static

Returns the parent directory of a given path.

For example, the parent directory of '/var/log/logs.tar.gz' is '/var/log', and the parent directory of '/var/log' (or '/var/log/') is '/var'. If the path consists of only a file separator, the same path is returned.

◆ relativePath()

static QString relativePath ( const QString &  path,
const QString &  prefix 
)
static

Returns the portion of a path that is relative to the given prefix path, or an empty string if the path does not begin with that prefix path.

◆ removeLastPathComponent()

static void removeLastPathComponent ( QString &  path)
static

Removes the last path component from the given path, that is, everything after and including the last file separator in the path.

If the path consists of a single path component starting with a file separator, returns a path consisting of just the file separator.


The documentation for this class was generated from the following file: