NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
path类 参考

文件路径类 更多...

#include <path.hpp>

类 path 继承关系图:
[图例]

class  split_iterator
 路径分割迭代器 更多...

Public 成员函数

 path ()=default
 默认构造函数,创建空路径
 path (string path) noexcept
 从字符串构造路径
 path (const string_view path)
 从字符串视图构造路径
 path (const char *path)
 从C风格字符串构造路径
const stringstr () const noexcept
 获取路径字符串
string_view view () const noexcept
 获取路径字符串视图
const char * data () const noexcept
 获取C风格字符串
bool empty () const noexcept
 检查路径是否为空
split_iterator begin () const
 获取起始路径组件迭代器
split_iterator end () const
 获取结束路径组件迭代器
path parent_path () const
 获取父路径
string_view filename () const noexcept
 获取文件名
string_view stem () const noexcept
 获取文件主名(不含扩展名)
string_view extension () const noexcept
 获取文件扩展名
path lexically_normal () const
 规范化路径
path absolute (const path &base=current_path()) const
 获取绝对路径
path relative (const path &base) const
 获取相对于另一路径的路径
pathoperator/= (const path &other)
 路径连接赋值操作符
pathoperator/= (string_view other)
 路径连接赋值操作符(字符串视图版本)
path operator/ (const path &other) const
 路径连接操作符
path operator/ (string_view pth) const
 路径连接操作符(字符串视图版本)
path_tree to_tree () const
 扫描此路径(必须为目录)并返回路径树
vector< pathchildren (bool include_hidden=false) const
 获取直接子路径列表(非递归)
vector< pathchild_files (bool include_hidden=false) const
 获取直接子文件路径列表
vector< pathchild_dirs (bool include_hidden=false) const
 获取直接子目录路径列表
bool exists () const noexcept
 检查路径是否存在
bool is_directory () const noexcept
 检查路径是否为目录
bool is_file () const noexcept
 检查路径是否为普通文件
 operator string_view () const noexcept
 转换为字符串视图
bool equal_to (const path &rhs) const
 相等比较
bool less_than (const path &rhs) const
 小于比较
size_t to_hash () const
 计算哈希值
string to_string () const
 转换为字符串
void swap (path &other) noexcept
 交换两个路径
Public 成员函数 继承自 icomparable< path >
constexpr bool operator== (const path &rhs) const noexcept(noexcept(derived().equal_to(rhs)))
 相等比较运算符
constexpr bool operator!= (const path &rhs) const noexcept(noexcept(!(derived().equal_to(rhs))))
 不等比较运算符
constexpr bool operator< (const path &rhs) const noexcept(noexcept(derived().less_than(rhs)))
 小于比较运算符
constexpr bool operator> (const path &rhs) const noexcept(noexcept(rhs.less_than(derived())))
 大于比较运算符
constexpr bool operator<= (const path &rhs) const noexcept(noexcept(!(rhs.less_than(derived()))))
 小于等于比较运算符
constexpr bool operator>= (const path &rhs) const noexcept(noexcept(!(derived().less_than(rhs))))
 大于等于比较运算符
Public 成员函数 继承自 ihashable< path >
constexpr size_t to_ihash () const noexcept(noexcept(derived().to_hash()))
 获取对象的哈希值
Public 成员函数 继承自 istringify< path >
constexpr string to_string () const
 转换为字符串

静态 Public 成员函数

static path current_path ()
 获取当前工作目录
static path temp_directory_path ()
 获取临时目录路径
static path current_executable_path ()
 获取当前可执行文件路径
static bool exists (const string &path) noexcept
 检查路径是否存在
static bool is_directory (const string &path) noexcept
 检查路径是否为目录
static bool is_file (const string &path) noexcept
 检查路径是否为文件
static string_view extension (string_view path) noexcept
 获取文件扩展名

静态 Public 属性

static constexpr size_t buffer_size = 8192
 文件操作缓冲区大小
static constexpr string_view spliter
 路径分隔符集合
static constexpr char preferred_separator = spliter[0]
 系统首选路径分隔符

详细描述

文件路径类

提供跨平台的文件路径操作,包括:

  • 路径组件访问(父路径、文件名、扩展名)
  • 路径规范化(解析.和..)
  • 路径组合(/操作符)
  • 文件系统操作(创建、删除、复制、移动)
  • 路径比较和哈希

在文件 path.hpp36 行定义.

构造及析构函数说明

◆ path() [1/3]

path::path ( string path)
inlineexplicitnoexcept

从字符串构造路径

参数
path路径字符串

在文件 path.hpp203 行定义.

引用了 path().

◆ path() [2/3]

path::path ( const string_view path)
inlineexplicit

从字符串视图构造路径

参数
path路径字符串视图

在文件 path.hpp210 行定义.

引用了 path().

◆ path() [3/3]

path::path ( const char * path)
inlineexplicit

从C风格字符串构造路径

参数
path路径C字符串

在文件 path.hpp217 行定义.

引用了 path().

成员函数说明

◆ absolute()

path path::absolute ( const path & base = current_path()) const
nodiscard

获取绝对路径

参数
base基础路径
返回
绝对路径

将相对路径转换为绝对路径。

引用了 absolute(), current_path() , 以及 path().

被这些函数引用 absolute().

◆ begin()

split_iterator path::begin ( ) const
inlinenodiscard

获取起始路径组件迭代器

返回
指向第一个组件的迭代器

在文件 path.hpp253 行定义.

◆ child_dirs()

vector< path > path::child_dirs ( bool include_hidden = false) const
nodiscard

获取直接子目录路径列表

参数
include_hidden是否包含隐藏目录
返回
子目录路径列表

引用了 child_dirs() , 以及 path().

被这些函数引用 child_dirs().

◆ child_files()

vector< path > path::child_files ( bool include_hidden = false) const
nodiscard

获取直接子文件路径列表

参数
include_hidden是否包含隐藏文件
返回
子文件路径列表

引用了 child_files() , 以及 path().

被这些函数引用 child_files().

◆ children()

vector< path > path::children ( bool include_hidden = false) const
nodiscard

获取直接子路径列表(非递归)

参数
include_hidden是否包含隐藏条目
返回
直接子路径列表

引用了 children() , 以及 path().

被这些函数引用 children().

◆ current_executable_path()

path path::current_executable_path ( )
static

获取当前可执行文件路径

返回
当前可执行文件路径

引用了 current_executable_path() , 以及 path().

被这些函数引用 current_executable_path().

◆ current_path()

path path::current_path ( )
static

获取当前工作目录

返回
当前工作目录路径

引用了 current_path() , 以及 path().

被这些函数引用 absolute() , 以及 current_path().

◆ data()

const char * path::data ( ) const
inlinenodiscardnoexcept

获取C风格字符串

返回
路径C字符串指针

在文件 path.hpp241 行定义.

◆ empty()

bool path::empty ( ) const
inlinenodiscardnoexcept

检查路径是否为空

返回
是否为空

在文件 path.hpp247 行定义.

◆ end()

split_iterator path::end ( ) const
inlinenodiscard

获取结束路径组件迭代器

返回
结束迭代器

在文件 path.hpp259 行定义.

◆ equal_to()

bool path::equal_to ( const path & rhs) const
nodiscard

相等比较

参数
rhs另一个路径
返回
是否相等

引用了 path().

◆ exists() [1/2]

bool path::exists ( ) const
nodiscardnoexcept

检查路径是否存在

返回
是否存在

引用了 exists().

被这些函数引用 exists() , 以及 exists().

◆ exists() [2/2]

bool path::exists ( const string & path)
staticnodiscardnoexcept

检查路径是否存在

参数
path要检查的路径字符串
返回
是否存在

引用了 exists() , 以及 path().

◆ extension() [1/2]

string_view path::extension ( ) const
nodiscardnoexcept

获取文件扩展名

返回
扩展名字符串视图

返回文件名的最后一个点之后的部分。

引用了 extension().

被这些函数引用 extension() , 以及 extension().

◆ extension() [2/2]

string_view path::extension ( string_view path)
staticnodiscardnoexcept

获取文件扩展名

参数
path路径字符串视图
返回
扩展名字符串视图

引用了 extension() , 以及 path().

◆ filename()

string_view path::filename ( ) const
nodiscardnoexcept

获取文件名

返回
文件名字符串视图

返回路径的最后一部分。

◆ is_directory() [1/2]

bool path::is_directory ( ) const
nodiscardnoexcept

检查路径是否为目录

返回
是否为目录

引用了 is_directory().

被这些函数引用 is_directory() , 以及 is_directory().

◆ is_directory() [2/2]

bool path::is_directory ( const string & path)
staticnodiscardnoexcept

检查路径是否为目录

参数
path要检查的路径字符串
返回
是否为目录

引用了 is_directory() , 以及 path().

◆ is_file() [1/2]

bool path::is_file ( ) const
nodiscardnoexcept

检查路径是否为普通文件

返回
是否为文件

引用了 is_file().

被这些函数引用 is_file() , 以及 is_file().

◆ is_file() [2/2]

bool path::is_file ( const string & path)
staticnodiscardnoexcept

检查路径是否为文件

参数
path要检查的路径字符串
返回
是否为文件

引用了 is_file() , 以及 path().

◆ less_than()

bool path::less_than ( const path & rhs) const
nodiscard

小于比较

参数
rhs另一个路径
返回
是否小于

引用了 path().

◆ lexically_normal()

path path::lexically_normal ( ) const
nodiscard

规范化路径

返回
规范化后的路径

解析路径中的"."和"..",移除多余的分隔符。

引用了 lexically_normal() , 以及 path().

被这些函数引用 lexically_normal() , 以及 to_string().

◆ operator/() [1/2]

path path::operator/ ( const path & other) const

路径连接操作符

参数
other要连接的路径
返回
连接后的新路径

引用了 path().

◆ operator/() [2/2]

path path::operator/ ( string_view pth) const

路径连接操作符(字符串视图版本)

参数
pth要连接的路径字符串视图
返回
连接后的新路径

引用了 path().

◆ operator/=() [1/2]

path & path::operator/= ( const path & other)

路径连接赋值操作符

参数
other要连接的路径
返回
自身引用

将另一个路径连接到当前路径,自动处理分隔符。

引用了 path().

◆ operator/=() [2/2]

path & path::operator/= ( string_view other)

路径连接赋值操作符(字符串视图版本)

参数
other要连接的路径字符串视图
返回
自身引用

引用了 path().

◆ parent_path()

path path::parent_path ( ) const
nodiscard

获取父路径

返回
父路径对象

引用了 path().

◆ relative()

path path::relative ( const path & base) const
nodiscard

获取相对于另一路径的路径

参数
base基础路径
返回
相对路径

计算当前路径相对于base路径的相对路径。

引用了 path() , 以及 relative().

被这些函数引用 relative().

◆ stem()

string_view path::stem ( ) const
nodiscardnoexcept

获取文件主名(不含扩展名)

返回
文件主名字符串视图

返回文件名去除最后一个点及之后的部分。

引用了 stem().

被这些函数引用 stem().

◆ str()

const string & path::str ( ) const
inlinenodiscardnoexcept

获取路径字符串

返回
路径字符串常量引用

在文件 path.hpp229 行定义.

引用了 str().

被这些函数引用 str().

◆ swap()

void path::swap ( path & other)
inlinenoexcept

交换两个路径

参数
other要交换的路径

在文件 path.hpp473 行定义.

引用了 path().

◆ temp_directory_path()

path path::temp_directory_path ( )
static

获取临时目录路径

返回
临时目录路径

引用了 path() , 以及 temp_directory_path().

被这些函数引用 temp_directory_path().

◆ to_hash()

size_t path::to_hash ( ) const
nodiscard

计算哈希值

返回
哈希值

◆ to_string()

string path::to_string ( ) const
inlinenodiscard

转换为字符串

返回
规范化后的路径字符串

在文件 path.hpp467 行定义.

引用了 lexically_normal().

◆ to_tree()

path_tree path::to_tree ( ) const
nodiscard

扫描此路径(必须为目录)并返回路径树

返回
路径树

引用了 to_tree().

被这些函数引用 to_tree().

◆ view()

string_view path::view ( ) const
inlinenodiscardnoexcept

获取路径字符串视图

返回
路径字符串视图

在文件 path.hpp235 行定义.

引用了 basic_string_view< CharT, Traits >::view().

类成员变量说明

◆ preferred_separator

char path::preferred_separator = spliter[0]
staticconstexpr

系统首选路径分隔符

用于构建系统原生路径。

在文件 path.hpp62 行定义.


该类的文档由以下文件生成: