std::experimental::filesystem::is_regular_file
来自cppreference.com
< cpp | experimental | fs
在标头 <experimental/filesystem> 定义
|
||
bool is_regular_file( file_status s ); |
(1) | (文件系统 TS) |
bool is_regular_file( const path& p ); |
(2) | (文件系统 TS) |
bool is_regular_file( const path& p, error_code& ec ); |
(3) | (文件系统 TS) |
检查给定的文件状态或路径是否对应于某个常规文件。
1) 等价于 s.type() == file_type::regular。
2) 等价于 is_regular_file(status(p))。
3) 等价于 is_regular_file(status(p, ec))。当发生错误时返回 false,并将 ec 设置为适当的错误码。否则,通过调用 ec.clear() 清除 ec。
本节未完成 原因:规范中说 (2) 在 status(p) 可能抛出 filesystem_error 时抛出 filesystem_error。这与其余 is_**_file 函数不同。这是否正确,以及若如此其原理为何? |
参数
s | - | 要检查的文件状态 |
p | - | 要检查的路径 |
ec | - | 要存储错误状态的错误码 |
返回值
如果给定的路径或文件状态对应于常规文件则为 true,否则为 false。
异常
1,3)
noexcept 规定:
noexcept
2) 当错误发生时抛出 filesystem_error。以 p 为实参构造异常对象。将错误码设为对于导致失败的错误适当的错误码。
参阅
本节未完成 |