| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <experimental/filesystem> | ||
path absolute(const path& p,const path& base= current_path()); | (1) | (filesystem TS) |
path system_complete(const path& p); path system_complete(const path& p, error_code& ec); | (2) | (filesystem TS) |
fs::current_path()). On Windows systems, each logical drive has its own current working directory, and so ifp 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.Contents |
| 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 |
Returns an absolute (although not necessarily canonical) path formed by combiningp andbase as described above.
On systems that support root names (e.g. Windows), the result of callingabsolute on a relative path that has a root name (e.g."D:file.txt" when the root name ofbase is different will usually result in a non-existent path.
#include <filesystem>#include <iostream>namespace fs= std::experimental::filesystem; int main(){ fs::path p="C:cl.exe";std::cout<<"Current path is "<< fs::current_path()<<'\n'<<"Absolute path for "<< p<<" is "<< fs::absolute(p)<<'\n'<<"System complete path for "<< p<<" is "<< fs::system_complete(p)<<'\n';}
Possible output:
Current path is "D:/local/ConsoleApplication1"Absolute path for "C:cl.exe" is "C:/local/ConsoleApplication1/cl.exe"System complete path for "C:cl.exe" is "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe"
| composes a canonical path (function)[edit] |