GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::filesystem::absolute(3) C++ Standard Libary std::filesystem::absolute(3)

std::filesystem::absolute - std::filesystem::absolute


Defined in header <filesystem>
path absolute(const std::filesystem::path& p); (since C++17)
path absolute(const std::filesystem::path& p, std::error_code& ec);


Returns a path referencing the same file system location as p, for which
filesystem::is_absolute() is true. The non-throwing overload returns
default-constructed path if an error occurs.


p - path to convert to absolute form
ec - out-parameter for error reporting in the non-throwing overload.


Returns an absolute (although not necessarily canonical) pathname referencing the
same file as p.


The overload that does not take a std::error_code& parameter throws
filesystem::filesystem_error on underlying OS API errors, constructed with p as the
first 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.


Implementations are encouraged to not consider p not existing to be an error.


For POSIX-based operating systems, std::filesystem::absolute(p) is equivalent to
std::filesystem::current_path() / p except for when p is the empty path.


For Windows, std::filesystem::absolute may be implemented as a call to
GetFullPathNameW.

// Run this code


#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
std::filesystem::path p = "foo.c";
std::cout << "Current path is " << fs::current_path() << '\n';
std::cout << "Absolute path for " << p << " is "
<< std::filesystem::absolute(p) << '\n';
}


Current path is "/tmp/1622355667.5363104"
Absolute path for "foo.c" is "/tmp/1622355667.5363104/foo.c"


canonical composes a canonical path
weakly_canonical (function)
(C++17)
relative composes a relative path
proximate (function)
(C++17)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.