1) Returns relative(p, current_path(), ec).
4) Returns proximate(p, current_path(), ec).
[edit] Parameters p - an existing path base - base path, against which p will be made relative/proximate ec - error code to store error status to [edit] Return value1) p made relative against current_path().
2,3) p made relative against base.
4) p made proximate against current_path().
5,6) p made proximate against base.
[edit] ExceptionsAny overload not marked noexcept
may throw std::bad_alloc if memory allocation fails.
Throws
std::filesystem::filesystem_erroron underlying OS API errors, constructed with
pas the first path argument,
baseas the second path argument, and the OS error code as the error code argument.
1,3,4,6)Sets a
std::error_code¶meter to the OS API error code if an OS API call fails, and executes
ec.clear()if no errors occur.
[edit] Example#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"); }
Possible output:
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"[edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4