• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <filesystem>

    std::filesystem::create_directory_symlink

    namespace std::filesystem {
      void create_directory_symlink(const path& to, const path& new_symlink); // (1)
      void create_directory_symlink(const path& to, const path& new_symlink,
                                    std::error_code& ec) noexcept;            // (2)
    }
    

    概要

    ディレクトリに対するシンボリックリンクを作成する。

    パスtoのディレクトリに対するシンボリックリンクをパスnew_symlinkに作成する。

    ファイルシステムによっては、ディレクトリに対するシンボリックリンクをcreate_symlink()関数で作成できない場合がある。より汎用的なプログラムを記述する場合に、この関数を使用する。

    効果

    • POSIX環境では、symlink()関数を使用して、パスtoのディレクトリに対するシンボリックリンクをパスnew_symlinkに作成する
      • パスtoは、パスnew_symlinkからの相対パスであることに注意

    戻り値

    なし

    例外

    #include <cassert>
    #include <filesystem>
    
    namespace fs = std::filesystem;
    
    int main()
    {
      fs::create_directory("dir");
    
      // dirに対するシンボリックリンクをdir_symlinkファイルとして作成する
      fs::create_directory_symlink("dir", "dir_symlink");
    
      assert(fs::exists("dir_symlink"));
      assert(fs::is_symlink("dir_symlink"));
    }
    

    出力

    バージョン

    言語

    • C++17

    処理系