std::filesystem::filesystem_error::path1, std::filesystem::filesystem_error::path2
De cppreference.com
< cpp | filesystem | filesystem error
conststd::filesystem::path& path1()constnoexcept; | (desde C++17) | |
conststd::filesystem::path& path2()constnoexcept; | (desde C++17) | |
Devuelve las rutas de acceso que se almacenaron en el objeto excepción.
[editar]Parámetros
(Ninguno)
[editar]Valor de retorno
Referencias a la copia de los parámetros path
almacenados por el constructor.
[editar]Ejemplo
Ejecuta este código
#include <cstdio>#include <filesystem>#include <iostream> int main(){conststd::filesystem::path ruta_antigua{std::tmpnam(nullptr)}, ruta_nueva{std::tmpnam(nullptr)};try{std::filesystem::rename(ruta_antigua, ruta_nueva);// lanza ya que ruta_antigua no existe}catch(std::filesystem::filesystem_errorconst& ex){std::cout<<"what(): "<< ex.what()<<'\n'<<"path1(): "<< ex.path1()<<'\n'<<"path2(): "<< ex.path2()<<'\n';}}
Posible salida:
what(): filesystem error: cannot rename: No such file or directory [/tmp/fileIzzRLB] [/tmp/fileiUDWlV] path1(): "/tmp/fileIzzRLB" path2(): "/tmp/fileiUDWlV"