Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::filesystem::filesystem_error::path1,std::filesystem::filesystem_error::path2

      From cppreference.com
      <cpp‎ |filesystem‎ |filesystem error
       
       
      Filesystem library
      Classes
      Functions
      File types
       
       
      conststd::filesystem::path& path1()constnoexcept;
      (since C++17)
      conststd::filesystem::path& path2()constnoexcept;
      (since C++17)

      Returns the paths that were stored in the exception object.

      [edit]Parameters

      (none)

      [edit]Return value

      References to the copy of thepath parameters stored by the constructor.

      [edit]Example

      Run this code
      #include <cstdio>#include <filesystem>#include <iostream> int main(){conststd::filesystem::path old_p{std::tmpnam(nullptr)},                                new_p{std::tmpnam(nullptr)};try{std::filesystem::rename(old_p, new_p);// throws since old_p does not exist}catch(std::filesystem::filesystem_errorconst& ex){std::cout<<"what():  "<< ex.what()<<'\n'<<"path1(): "<< ex.path1()<<'\n'<<"path2(): "<< ex.path2()<<'\n';}}

      Possible output:

      what():  filesystem error: cannot rename: No such file or directory [/tmp/fileIzzRLB] [/tmp/fileiUDWlV]path1(): "/tmp/fileIzzRLB"path2(): "/tmp/fileiUDWlV"
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/filesystem/filesystem_error/path&oldid=128562"

      [8]ページ先頭

      ©2009-2026 Movatter.jp