std::experimental::filesystem::absolute,std::experimental::filesystem::system_complete (3) - Linux Manuals
std::experimental::filesystem::absolute,std::experimental::filesystem::system_complete: std::experimental::filesystem::absolute,std::experimental::filesystem::system_complete
NAME
std::experimental::filesystem::absolute,std::experimental::filesystem::system_complete - std::experimental::filesystem::absolute,std::experimental::filesystem::system_complete
Synopsis
Defined in header <experimental/filesystem>
path absolute( const path& p, const path& base = current_path() ); (1) (filesystem TS)
path system_complete(const path& p); (2) (filesystem TS)
path system_complete(const path& p, error_code& ec);
1) Returns absolute path of p relative to base according to the following rules:
2) Obtains the absolute path that identifies the file that the OS file opening API would access given the pathname p. On POSIX systems, this is equivalent to (1) with the default base (fs::current_path()). On Windows systems, each logical drive has its own current working directory, and so if p is not already absolute and has a root name component (e.g. "E:filename.txt", that drive's current working directory is used, which may have been set by an earlier executed program.
Parameters
p - path to convert to absolute form
base - path (not necessarily absolute) to serve as the starting location
ec - out-parameter for error reporting in the non-throwing overload
Return value
Returns an absolute (although not necessarily canonical) path formed by combining p and base as described above.
Exceptions
The overload that does not take a error_code& parameter throws filesystem_error on underlying OS API errors, constructed with p as the first argument, base as the second argument, and the OS error code as the error code argument. std::bad_alloc may be thrown if memory allocation fails. The overload taking a 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. This overload has
noexcept specification:
noexcept
Notes
On systems that support root names (e.g. Windows), the result of calling absolute on a relative path that has a root name (e.g. "D:file.txt" when the root name of base is different will usually result in a non-existent path.
Example
// Run this code
Possible output:
See also
canonical (function)