std::experimental::filesystem::canonical
Min standard notice:
Header: <experimental/filesystem>
Converts path p to a canonical absolute path, i.e. an absolute path that has no dot, dot-dot elements or symbolic links.
# Declarations
path canonical( const path& p, const path& base = current_path() );
(filesystem TS)
path canonical( const path& p, error_code& ec );
(filesystem TS)
path canonical( const path& p, const path& base, error_code& ec );
(filesystem TS)
# Parameters
p: a path which may be absolute or relative to base, and which must be an existing pathbase: base path to be used in case p is relativeec: error code to store error status to
# Return value
An absolute path that resolves to the same file as absolute(p, base) (or absolute(p) for (2)).
# Example
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p = fs::path("..") / ".." / "AppData";
std::cout << "Current path is " << fs::current_path() << '\n'
<< "Canonical path for " << p << " is " << fs::canonical(p) << '\n';
}