std::filesystem:: relative, std::filesystem:: proximate
|
Definido en el encabezado
<filesystem>
|
||
|
path relative
(
const
std::
filesystem
::
path
&
p,
std:: error_code & ec ) ; |
(1) | (desde C++17) |
|
path relative
(
const
std::
filesystem
::
path
&
p,
const std:: filesystem :: path & base = std:: filesystem :: current_path ( ) ) ; |
(2) | (desde C++17) |
|
path relative
(
const
std::
filesystem
::
path
&
p,
const
std::
filesystem
::
path
&
base,
|
(3) | (desde C++17) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
std:: error_code & ec ) ; |
(4) | (desde C++17) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
const std:: filesystem :: path & base = std:: filesystem :: current_path ( ) ) ; |
(5) | (desde C++17) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
const
std::
filesystem
::
path
&
base,
|
(6) | (desde C++17) |
Contenidos |
Parámetros
| p | - | una ruta existente |
| base | - | ruta base, contra la cual p será hecho relativo/proximal |
| ec | - | código de error para almacenar el estado de error |
Valor de retorno
Excepciones
Cualquier sobrecarga no marcada como
noexcept
puede lanzar
std::bad_alloc
si la asignación de memoria falla.
Ejemplo
#include <filesystem> #include <iostream> void show(std::filesystem::path x, std::filesystem::path y) { std::cout << "x:\t\t " << x << "\ny:\t\t " << y << '\n' << "relative(x, y): " << std::filesystem::relative(x, y) << '\n' << "proximate(x, y): " << std::filesystem::proximate(x, y) << "\n\n"; } int main() { show("/a/b/c", "/a/b"); show("/a/c", "/a/b"); show("c", "/a/b"); show("/a/b", "c"); }
Salida posible:
x: "/a/b/c" y: "/a/b" relative(x, y): "c" proximate(x, y): "c" x: "/a/c" y: "/a/b" relative(x, y): "../c" proximate(x, y): "../c" x: "c" y: "/a/b" relative(x, y): "" proximate(x, y): "c" x: "/a/b" y: "c" relative(x, y): "" proximate(x, y): "/a/b"
Véase también
|
(C++17)
|
representa una ruta
(clase) |
|
(C++17)
|
compone una ruta absoluta
(función) |
|
(C++17)
|
compone una ruta canónica
(función) |
|
convierte la ruta a forma normal
convierte la ruta a forma relativa convierte la ruta a forma próxima (función miembro pública de
std::filesystem::path
)
|