• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <filesystem>

    std::filesystem::directory_entry::is_other

    bool is_other() const;                             // (1)
    bool is_other(std::error_code& ec) const noexcept; // (2)
    

    概要

    パスが存在していない、もしくはシステム依存の種別のファイルを指しているかを確認する。

    戻り値

    例外

    #include <iostream>
    #include <filesystem>
    #include <fstream>
    
    namespace fs = std::filesystem;
    
    int main()
    {
      fs::create_directory("dir");
      fs::create_directory("dir/inner_dir");
      std::ofstream{"dir/a.txt"};
    
      std::cout << std::boolalpha;
      for (const fs::directory_entry& x : fs::directory_iterator("dir")) {
        std::cout << x.path() << " : " << x.is_other() << std::endl;
      }
    }
    

    出力例

    "dir/inner_dir" : false
    "dir/a.txt" : false
    

    バージョン

    言語

    • C++17

    処理系