Espacios de nombres
Variantes
Acciones

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

De cppreference.com
 
 
 
 
const std::filesystem::path& path1() const noexcept;
(desde C++17)
const std::filesystem::path& path2() const noexcept;
(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

#include <cstdio>
#include <filesystem>
#include <iostream>
 
int main()
{
    const std::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_error const& 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"