uicore::FilePath Class Reference

Path helper functions. More...

#include <path_help.h>

Static Public Member Functions

static std::string absolute_path (std::string path)
 Returns the absolute file system path for the given path. More...
 
static std::string add_trailing_slash (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Add trailing slash or backslash to path. More...
 
static std::string basepath (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Returns a new path with the last path component removed. More...
 
static std::string combine (const std::string &part1, const std::string &part2, FilePathType path_type=FilePathType::file_system)
 Concatenates two strings into one adding a trailing slash to first string if missing. More...
 
static std::string extension (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Returns the extension part (includes the dot) of a path. More...
 
static std::string filename (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Returns the filename part of a path. More...
 
static std::string filename_without_extension (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Returns the filename part without the extension. More...
 
static bool has_extension (const std::string &path, const std::string &extension, FilePathType path_type=FilePathType::file_system)
 Checks if the path has the specified extension. More...
 
static bool is_absolute (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Check if a path is absolute. More...
 
static bool is_relative (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Check if a path is relative. More...
 
static std::string location (const std::string &path)
 Returns the drive (C:) or share name ( \ \ computer \ share) More...
 
static std::string make_absolute (const std::string &base_path, const std::string &relative_path, FilePathType path_type=FilePathType::file_system)
 Changes a path to be relative to the specified base path, if possible. More...
 
static std::string make_relative (const std::string &base_path, const std::string &absolute_path, FilePathType path_type=FilePathType::file_system)
 Changes a path to be relative to the specified base path, if possible. More...
 
static std::string normalize (const std::string &path, FilePathType path_type=FilePathType::file_system)
 Normalize a path. More...
 
static std::string remove_trailing_slash (const std::string &path)
 Remove trailing slash or backslash from path. More...
 

Detailed Description

Path helper functions.

Member Function Documentation

static std::string uicore::FilePath::absolute_path ( std::string  path)
static

Returns the absolute file system path for the given path.

static std::string uicore::FilePath::add_trailing_slash ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Add trailing slash or backslash to path.

This function checks if a path already has a trailing slash/backslash and adds it if its missing.

Parameters
pathThe path to use
path_typeThe path type (of path)
Returns
The converted path
static std::string uicore::FilePath::basepath ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Returns a new path with the last path component removed.

static std::string uicore::FilePath::combine ( const std::string part1,
const std::string part2,
FilePathType  path_type = FilePathType::file_system 
)
static

Concatenates two strings into one adding a trailing slash to first string if missing.

Parameters
part1First part of path
part2Second part of path
path_typeThe path type (of path)
static std::string uicore::FilePath::extension ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Returns the extension part (includes the dot) of a path.

static std::string uicore::FilePath::filename ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Returns the filename part of a path.

static std::string uicore::FilePath::filename_without_extension ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Returns the filename part without the extension.

static bool uicore::FilePath::has_extension ( const std::string path,
const std::string extension,
FilePathType  path_type = FilePathType::file_system 
)
static

Checks if the path has the specified extension.

static bool uicore::FilePath::is_absolute ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Check if a path is absolute.

Parameters
pathThe path to check
path_typeThe path type (of path)
Returns
true if path is absolute
static bool uicore::FilePath::is_relative ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Check if a path is relative.

Parameters
pathThe path to check
path_typeThe path type (of path)
Returns
true if path is relative
static std::string uicore::FilePath::location ( const std::string path)
static

Returns the drive (C:) or share name ( \ \ computer \ share)

static std::string uicore::FilePath::make_absolute ( const std::string base_path,
const std::string relative_path,
FilePathType  path_type = FilePathType::file_system 
)
static

Changes a path to be relative to the specified base path, if possible.

static std::string uicore::FilePath::make_relative ( const std::string base_path,
const std::string absolute_path,
FilePathType  path_type = FilePathType::file_system 
)
static

Changes a path to be relative to the specified base path, if possible.

static std::string uicore::FilePath::normalize ( const std::string path,
FilePathType  path_type = FilePathType::file_system 
)
static

Normalize a path.

Parameters
pathThe path to use
path_typeThe path type (of the normalized path)
Returns
The converted path

Converts all slashes and backslashes into their right type. Simplifies or removes all . and .., converting the path into its most readable form.

static std::string uicore::FilePath::remove_trailing_slash ( const std::string path)
static

Remove trailing slash or backslash from path.

This function checks if a path has a trailing slash/backslash and removes it if needed.

Parameters
pathThe path to use
Returns
The converted path

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