Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CPath Class Reference

Path manipulation helpers for engine resource and file paths. More...

#include <Utils/CPath.h>

Static Public Member Functions

static const std::string & getFileName (const std::string &path)
 Get the file name, including extension, from a path.
static const std::string & getFileNameExt (const std::string &path)
 Get only the extension from a file path.
static const std::string & getFileNameNoExt (const std::string &path)
 Get the file name without its extension.
static const std::string & replaceFileExt (const std::string &path, const std::string &ext)
 Replace the extension of a file path.
static const std::string & getFolderPath (const std::string &path)
 Get the folder portion of a path.
static const std::string & getParentFolderPath (const std::string &path)
 Get the parent folder of a path or folder.
static const std::string & normalizePath (const std::string &path)
 Normalize slashes and collapse .. path elements.
static const std::string & getRelativePath (const std::string &path, const std::string &folder)
 Convert a path to be relative to a folder when they share a root.
static bool searchMatch (const std::string &path, const std::string &searchPattern)
 Match a file name against a simple wildcard pattern.

Detailed Description

Path manipulation helpers for engine resource and file paths.

Most methods return a reference to a shared temporary string. Copy the returned value before calling another utility that may reuse the same temporary buffer.

Member Function Documentation

◆ getFileName()

const std::string & Skylicht::CPath::getFileName ( const std::string & path)
static

Get the file name, including extension, from a path.

Parameters
pathInput path.
Returns
File name stored in the shared temporary buffer.

◆ getFileNameExt()

const std::string & Skylicht::CPath::getFileNameExt ( const std::string & path)
static

Get only the extension from a file path.

Parameters
pathInput path.
Returns
Extension without the dot, or an empty string when no extension exists.

◆ getFileNameNoExt()

const std::string & Skylicht::CPath::getFileNameNoExt ( const std::string & path)
static

Get the file name without its extension.

Parameters
pathInput path.
Returns
File name without extension.

◆ getFolderPath()

const std::string & Skylicht::CPath::getFolderPath ( const std::string & path)
static

Get the folder portion of a path.

Parameters
pathInput path.
Returns
Folder path without the file name.

◆ getParentFolderPath()

const std::string & Skylicht::CPath::getParentFolderPath ( const std::string & path)
static

Get the parent folder of a path or folder.

Parameters
pathInput path.
Returns
Parent folder path.

◆ getRelativePath()

const std::string & Skylicht::CPath::getRelativePath ( const std::string & path,
const std::string & folder )
static

Convert a path to be relative to a folder when they share a root.

Parameters
pathAbsolute or base path to convert.
folderFolder used as the relative origin.
Returns
Relative path, or the original path when no shared root exists.

◆ normalizePath()

const std::string & Skylicht::CPath::normalizePath ( const std::string & path)
static

Normalize slashes and collapse .. path elements.

Parameters
pathInput path.
Returns
Normalized path.

◆ replaceFileExt()

const std::string & Skylicht::CPath::replaceFileExt ( const std::string & path,
const std::string & ext )
static

Replace the extension of a file path.

Parameters
pathInput path.
extNew extension.
Returns
Path with the new extension.

◆ searchMatch()

bool Skylicht::CPath::searchMatch ( const std::string & path,
const std::string & searchPattern )
static

Match a file name against a simple wildcard pattern.

Supports ? for one character and * for a variable number of characters. Matching is case-insensitive.

Parameters
pathPath whose file name will be tested.
searchPatternPattern to match.
Returns
True if the file name matches the pattern.

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