KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
PathUtil Class Reference

PathUtil. More...

#include <pathutil.h>

Static Public Member Functions

static QString fileName (const QString &path)
 Extract the basename from a file path.
 
static QString dirName (const QString &path)
 Extract the directory portion from a file path.
 
static QString extension (const QString &path)
 Extract the file extension from a file path.
 
static QString trimTrailingSlash (const QString &path)
 Remove a trailing directory separator from a path.
 
static QString combine (const QString &p1, const QString &p2)
 Combine two path segments into a normalized path.
 
static QString combine (const QString &p1, const QString &p2, const QString &p3)
 Combine three path segments into a normalized path.
 
static QString combine (const QString &p1, const QString &p2, const QString &p3, const QString &p4)
 Combine four path segments into a normalized path.
 
static QString combine (const QString &p1, const QString &p2, const QString &p3, const QString &p4, const QString &p5)
 Combine five path segments into a normalized path.
 
static QString combine (const QString &p1, const QString &p2, const QString &p3, const QString &p4, const QString &p5, const QString &p6)
 Combine six path segments into a normalized path.
 
static QString combine (const QString &p1, const QString &p2, const QString &p3, const QString &p4, const QString &p5, const QString &p6, const QString &p7)
 Combine seven path segments into a normalized path.
 
static QString combine (const QStringList &parts)
 Combine a list of path segments into a normalized path.
 
static QFileInfo which (const QString &basename)
 Find the first executable in PATH matching a basename.
 
static QString popLevel (const QString &path)
 Return the given directory with one level removed.
 

Detailed Description

PathUtil.

Some static helper methods for files. Much of the functionallity in here has been overtaken by the QFileInfo native Qt object.

However, the extremely useful combine() method will combine many strings into a well-formatted path name.

Stephen Punak, July 04 2019

Static helper methods for filesystem path manipulation.

Definition at line 21 of file pathutil.h.

Member Function Documentation

◆ combine() [1/7]

static QString PathUtil::combine ( const QString &  p1,
const QString &  p2 
)
inlinestatic

Combine two path segments into a normalized path.

Parameters
p1First segment
p2Second segment
Returns
Cleaned combined path

Definition at line 62 of file pathutil.h.

◆ combine() [2/7]

static QString PathUtil::combine ( const QString &  p1,
const QString &  p2,
const QString &  p3 
)
inlinestatic

Combine three path segments into a normalized path.

Parameters
p1First segment
p2Second segment
p3Third segment
Returns
Cleaned combined path

Definition at line 72 of file pathutil.h.

◆ combine() [3/7]

static QString PathUtil::combine ( const QString &  p1,
const QString &  p2,
const QString &  p3,
const QString &  p4 
)
inlinestatic

Combine four path segments into a normalized path.

Parameters
p1First segment
p2Second segment
p3Third segment
p4Fourth segment
Returns
Cleaned combined path

Definition at line 83 of file pathutil.h.

◆ combine() [4/7]

static QString PathUtil::combine ( const QString &  p1,
const QString &  p2,
const QString &  p3,
const QString &  p4,
const QString &  p5 
)
inlinestatic

Combine five path segments into a normalized path.

Parameters
p1First segment
p2Second segment
p3Third segment
p4Fourth segment
p5Fifth segment
Returns
Cleaned combined path

Definition at line 95 of file pathutil.h.

◆ combine() [5/7]

static QString PathUtil::combine ( const QString &  p1,
const QString &  p2,
const QString &  p3,
const QString &  p4,
const QString &  p5,
const QString &  p6 
)
inlinestatic

Combine six path segments into a normalized path.

Parameters
p1First segment
p2Second segment
p3Third segment
p4Fourth segment
p5Fifth segment
p6Sixth segment
Returns
Cleaned combined path

Definition at line 108 of file pathutil.h.

◆ combine() [6/7]

static QString PathUtil::combine ( const QString &  p1,
const QString &  p2,
const QString &  p3,
const QString &  p4,
const QString &  p5,
const QString &  p6,
const QString &  p7 
)
inlinestatic

Combine seven path segments into a normalized path.

Parameters
p1First segment
p2Second segment
p3Third segment
p4Fourth segment
p5Fifth segment
p6Sixth segment
p7Seventh segment
Returns
Cleaned combined path

Definition at line 122 of file pathutil.h.

◆ combine() [7/7]

static QString PathUtil::combine ( const QStringList &  parts)
static

Combine a list of path segments into a normalized path.

Parameters
partsList of path segment strings
Returns
Cleaned combined path

◆ dirName()

static QString PathUtil::dirName ( const QString &  path)
static

Extract the directory portion from a file path.

Parameters
pathFile path string
Returns
Directory portion of the path
Deprecated:
Prefer QFileInfo::filePath()

◆ extension()

static QString PathUtil::extension ( const QString &  path)
static

Extract the file extension from a file path.

Parameters
pathFile path string
Returns
Extension string (without leading dot)
Deprecated:
Prefer QFileInfo::suffix()

◆ fileName()

static QString PathUtil::fileName ( const QString &  path)
static

Extract the basename from a file path.

Parameters
pathFile path string
Returns
Filename portion of the path
Deprecated:
Prefer QFileInfo::baseName()

◆ popLevel()

static QString PathUtil::popLevel ( const QString &  path)
static

Return the given directory with one level removed.

Parameters
pathDirectory path to shorten
Returns
Parent directory path

◆ trimTrailingSlash()

static QString PathUtil::trimTrailingSlash ( const QString &  path)
static

Remove a trailing directory separator from a path.

Parameters
pathPath string to trim
Returns
Path without trailing separator
Deprecated:
Prefer QFileInfo::suffix()

◆ which()

static QFileInfo PathUtil::which ( const QString &  basename)
static

Find the first executable in PATH matching a basename.

Parameters
basenameExecutable filename to search for
Returns
QFileInfo for the found executable, or an invalid QFileInfo if not found

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