Share via


directory_entry 类

描述由 *X返回的对象,其中 Xdirectory_iteratorrecursive_directory_iterator

语法

class directory_entry;

备注

该类存储 path 类型的对象。 存储的 path 可以是 path 类的实例或从 path 派生的类型的实例。 它还存储两个 file_type 值。 一个值表示存储的文件名的状态。 另一个表示文件名的符号链接状态。

有关详细信息和代码示例,请参阅文件系统导航 (C++)

构造函数

构造函数 说明
directory_entry 默认构造函数行为符合预期。 第四个构造函数将 mypath 初始化为 pval,将 mystat 初始化为 stat_arg,并将 mysymstat 初始化为 symstat_arg

成员函数

成员函数 说明
assign 成员函数将 pval 分配到 mypath,将 stat 分配到 mystat,并将 symstat 分配到 mysymstat
路径 成员函数返回 mypath
replace_filename 成员函数将 mypath 替换为 mypath.parent_path() / pval,将 mystat 替换为 stat_arg,并将 mysymstat 替换为 symstat_arg
status 这两个成员函数均返回首次经过更改的 mystat
symlink_status 这两个成员函数均返回首次经过更改的 mysymstat

运算符

运算符 说明
operator!= 用另一个列表的副本替换列表中的元素。
operator= 默认成员赋值运算符的行为符合预期。
operator== 返回 mypath == right.mypath
operator< 返回 mypath < right.mypath
operator<= 返回 !(right < *this)
operator> 返回 right < *this
operator>= 返回 !(*this < right)
operator const path_type& 返回 mypath

要求

标头:<experimental/filesystem>

命名空间:std::experimental::filesystem

assign

成员函数将 pval 分配到 mypath,stat_arg 分配到 mystat,并将 symstat_arg 分配到 mysymstat

void assign(const std::experimental::filesystem::path& pval,
    file_status stat_arg = file_status(),
    file_status symstat_arg = file_status());

参数

pval
存储的文件名路径。

stat_arg
存储文件名的状态。

symstat_arg
已存储文件名的符号链接状态。

directory_entry

默认构造函数行为符合预期。 第四个构造函数将 mypath 初始化为 pval,将 mystat 初始化为 stat_arg,并将 mysymstat 初始化为 symstat_arg

directory_entry() = default;
directory_entry(const directory_entry&) = default;
directory_entry(directory_entry&&) noexcept = default;
explicit directory_entry(const std::experimental::filesystem::path& pval,
    file_status stat_arg = file_status(),
    file_status symstat_arg = file_status());

参数

pval
存储的文件名路径。

stat_arg
存储文件名的状态。

symstat_arg
已存储文件名的符号链接状态。

operator!=

成员函数返回 !(*this == right)

bool operator!=(const directory_entry& right) const noexcept;

参数

right
正在与 directory_entry 比较的 directory_entry

operator=

默认成员赋值运算符的行为符合预期。

directory_entry& operator=(const directory_entry&) = default;
directory_entry& operator=(directory_entry&&) noexcept = default;

参数

right
正在复制到 directory_entrydirectory_entry

operator==

成员函数返回 mypath == right.mypath

bool operator==(const directory_entry& right) const noexcept;

参数

right
正在与 directory_entry 比较的 directory_entry

operator<

成员函数返回 mypath < right.mypath

bool operator<(const directory_entry& right) const noexcept;

参数

right
正在与 directory_entry 比较的 directory_entry

operator<=

成员函数返回 !(right < *this)

bool operator<=(const directory_entry& right) const noexcept;

参数

right
正在与 directory_entry 比较的 directory_entry

operator>

成员函数返回 right < *this

bool operator>(const directory_entry& right) const noexcept;

参数

right
正在与 directory_entry 比较的 directory_entry

operator>=

成员函数返回 !(*this < right)

bool operator>=(const directory_entry& right) const noexcept;

参数

right
正在与 directory_entry 比较的 directory_entry

operator const path_type&

该成员运算符将返回 mypath

operator const std::experimental::filesystem::path&() const;

path

成员函数返回 mypath

const std::experimental::filesystem::path& path() const noexcept;

replace_filename

成员函数将 mypath 替换为 mypath.parent_path() / pval,将 mystat 替换为 stat_arg,并将 mysymstat 替换为 symstat_arg

void replace_filename(
    const std::experimental::filesystem::path& pval,
    file_status stat_arg = file_status(),
    file_status symstat_arg = file_status());

参数

pval
存储的文件名路径。

stat_arg
存储文件名的状态。

symstat_arg
已存储文件名的符号链接状态。

status

这两个成员函数均返回第一次可能按如下更改的 mystat

  1. 如果 status_known(mystat),则不执行任何操作。

  2. 否则,如果 !status_known(mysymstat) && !is_symlink(mysymstat),则 mystat = mysymstat

file_status status() const;
file_status status(error_code& ec) const noexcept;

参数

ec
状态错误代码。

这两个成员函数均返回第一次可能按如下更改的 mysymstat:如果为 status_known(mysymstat),则不执行任何操作。 否则为 mysymstat = symlink_status(mypval)

file_status symlink_status() const;
file_status symlink_status(error_code& ec) const noexcept;

参数

ec
状态错误代码。

另请参阅

头文件引用
<filesystem>