stdfilesystemrelativestdfilesystemproximate(3)
std::filesystem::relative,std::filesystem::proximate - std::filesystem::relative,std::filesystem::proximate
Synopsis
Defined in header<filesystem>
path relative(const std::filesystem::path &p, (1)(since C++ 17)
std::error_code &ec);
path relative(const std::filesystem::path &p,
const std::filesystem::path &base = std::filesystem::current_path());
path relative(const std::filesystem::path &p, (2)(since C++ 17)
const std::filesystem::path &base,
std::error_code &ec);
path proximate(const std::filesystem::path &p, (3)(since C++ 17)
std::error_code &ec);
path proximate(const std::filesystem::path &p,
const std::filesystem::path &base = std::filesystem::current_path());
path proximate(const std::filesystem::path &p, (4)(since C++ 17)
const std::filesystem::path &base,
std::error_code &ec);- Returns relative(p, current_path(), ec)
- Returns p made relative to base. Resolves symlinks and normalizes both p and base before other processing. Effectively returns weakly_canonical(p).lexically_relative(weakly_canonical(base)) or weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec)), except the error code form returns path() at the first error occurrence, if any.
- Returns proximate(p, current_path(), ec)
- Effectively returns weakly_canonical(p).lexically_proximate(weakly_canonical(base)) or weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec)), except the error code form returns path() at the first error occurrence, if any.
Parameters
p - an existing path base - base path, against which p will be made relative/proximate ec - error code to store error status to
Return value
- p made relative against base.
- p made proximate against base
Exceptions
The overload that does not take a std::error_code& parameter throws filesystem_error on underlying OS API errors, constructed with p as the first path argument, base as the second path argument, and the OS error code as the error code argument. The overload taking a std::error_code& parameter sets it to the OS API error code if an OS API call fails, and executes ec.clear() if no errors occur. Any overload not marked noexcept may throw std::bad_alloc if memory allocation fails.
Example
This section is incomplete Reason: no example
See also
path represents a path