std::filesystem::is_other

定义于头文件 <filesystem>
bool is_other( std::filesystem::file_status s ) noexcept;
(1) (C++17 起)
bool is_other( const std::filesystem::path& p );
bool is_other( const std::filesystem::path& p, std::error_code& ec ) noexcept;
(2) (C++17 起)

检查给定文件状态或路径是否对应其他类型的文件。即文件存在,但既非常规文件,亦非目录或符号链接。

1) 等价于 exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s)
2) 各等价于 is_other(status(p))is_other(status(p, ec))

目录

参数

s - 要检查的文件状态
p - 要检验的路径
ec - 存储错误状态的错误码

返回值

p 所指示的文件或 s 所指示的类型指代不是常规文件、目录或符号链接则为 true ,否则为 false 。不抛出重载在错误发生时返回 false

异常

2) 不接受 std::error_code& 参数的重载在底层 OS API 错误时抛出 filesystem_error ,以第一参数 p 和作为错误码参数的 OS 错误码构造。若内存分配失败则可能抛出 std::bad_alloc 。若 OS API 调用失败,则接受 std::error_code& 参数的重载设置该参数为 OS API 错误码,而若不出现错误则执行 ec.clear()

示例

参阅

(C++17)
(C++17)
确定文件属性
确定文件属性,检查符号链接对象
(函数)
(C++17)
表示文件类型及权限
(类)
(C++17)
检查文件状态是否已知
(函数)
检查给定的路径是否表示阻塞设备
(函数)
检查给定的路径是否表示字符设备
(函数)
(C++17)
检查给定的路径是否表示一个目录
(函数)
(C++17)
检查给定的路径是否表示一个具名管道
(函数)
检查参数是否表示一个常规文件
(函数)
(C++17)
检查参数是否表示一个具名 IPC 接头
(函数)
(C++17)
检查参数是否表示一个符号链接
(函数)
(C++17)
检查路径是否表示既存的文件系统对象
(函数)
检查 directory_entry 是否代表其他文件
(std::filesystem::directory_entry 的公开成员函数)

版本历史

  • (当前 | 先前 2017年6月27日 (二) 05:47Fruderica讨论 | 贡献 . . (1,771字节) (-10). . (撤销)
  • 当前 | 先前) 2017年5月1日 (一) 00:55Fruderica讨论 | 贡献. . (1,781字节) (+1,781). . (以“{{cpp/filesystem/title|is_other}} {{cpp/filesystem/navbar}} {{dcl begin}} {{dcl header | filesystem}} {{dcl | num=1 | since=c++17 | 1= bool is_other( std::filesystem...”为内容创建页面)