std::filesystem:: relative, std::filesystem:: proximate
|
Definiert im Header
<filesystem>
|
||
|
path relative
(
const
std::
filesystem
::
path
&
p,
std:: error_code & ec ) ; |
(1) | (seit C++17) |
|
path relative
(
const
std::
filesystem
::
path
&
p,
const std:: filesystem :: path & base = std:: filesystem :: current_path ( ) ) ; |
(2) | (seit C++17) |
|
path relative
(
const
std::
filesystem
::
path
&
p,
const
std::
filesystem
::
path
&
base,
|
(3) | (seit C++17) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
std:: error_code & ec ) ; |
(4) | (seit C++17) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
const std:: filesystem :: path & base = std:: filesystem :: current_path ( ) ) ; |
(5) | (seit C++17) |
|
path proximate
(
const
std::
filesystem
::
path
&
p,
const
std::
filesystem
::
path
&
base,
|
(6) | (seit C++17) |
Inhaltsverzeichnis |
Parameter
| p | - | ein bestehender Pfad |
| base | - | Basis-Pfad, relativ zu dem p relativ/proximal gemacht wird |
| ec | - | Fehlercode zur Speicherung des Fehlerstatus |
Rückgabewert
Exceptions
Jede Überladung, die nicht als
noexcept
gekennzeichnet ist, kann
std::bad_alloc
auslösen, wenn die Speicherallokation fehlschlägt.
Beispiel
#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"); }
Mögliche Ausgabe:
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"
Siehe auch
|
(C++17)
|
repräsentiert einen Pfad
(Klasse) |
|
(C++17)
|
erstellt einen absoluten Pfad
(Funktion) |
|
(C++17)
|
erstellt einen kanonischen Pfad
(Funktion) |
|
konvertiert Pfad in Normalform
konvertiert Pfad in relative Form konvertiert Pfad in proximale Form (öffentliche Elementfunktion von
std::filesystem::path
)
|