| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Path decomposition | ||||
| Non-member functions | ||||
Defined in header <experimental/filesystem> | ||
class path; | (filesystem TS) | |
Objects of typepath represent paths on a filesystem. Only syntactic aspects of paths are handled: the pathname may represent a non-existing path or even one that is not allowed to exist on the current file system or OS.
The path name has the following syntax:
path::preferred_separator. If this character is repeated, it is treated as a single directory separator:/usr///////lib is the same as/usr/lib.The path can be traversed element-wise via iterators returned by thebegin() andend() functions, which iterates over root name, root directory, and the subsequent file name elements (directory separators are skipped except the one that identifies the root directory). If the very last element in the path is a directory separator, the last iterator will dereference to a file namedot.
Calling any non-const member function of apath invalidates all iterators referring to elements of that object.
If the OS uses anative syntax that is different from the portablegeneric syntax described above, all library functions accept path names in both formats.
Paths are implicitly convertible to and fromstd::basic_strings, which makes it possible to use them with other file APIs, e.g. as an argument tostd::ifstream::open.
Contents |
| Type | Definition |
value_type | character type used by the native encoding of the filesystem:char on POSIX,wchar_t on Windows |
string_type | std::basic_string<value_type> |
const_iterator | a constantLegacyBidirectionalIterator with avalue_type ofpath |
iterator | an alias toconst_iterator |
constexpr value_type preferred_separator [static] | alternative directory separator which may be used in addition to the portable/. On Windows, this is the backslash character\. On POSIX, this is the same forward slash/ as the portable separator (public static member constant) |
constructs apath(public member function)[edit] | |
destroys apath object(public member function)[edit] | |
| assigns another path (public member function)[edit] | |
| assigns contents (public member function)[edit] | |
Concatenation | |
| appends elements to the path (public member function)[edit] | |
| concatenates two paths without introducing a directory separator (public member function)[edit] | |
Modifiers | |
| erases the contents (public member function)[edit] | |
| converts directory separators to preferred directory separator (public member function)[edit] | |
| removes filename path component (public member function)[edit] | |
| replaces the last path component with another path (public member function)[edit] | |
| replaces the extension (public member function)[edit] | |
| swaps two paths (public member function)[edit] | |
Format observers | |
| returns the native version of the path (public member function)[edit] | |
| returns the path in native pathname format converted to a string (public member function)[edit] | |
| returns the path in generic pathname format converted to a string (public member function)[edit] | |
Compare | |
| compares the lexical representations of two paths lexicographically (public member function)[edit] | |
Decomposition | |
| returns the root-name of the path, if present (public member function)[edit] | |
| returns the root directory of the path, if present (public member function)[edit] | |
| returns the root path of the path, if present (public member function)[edit] | |
| returns path relative to the root path (public member function)[edit] | |
| returns the path of the parent path (public member function)[edit] | |
| returns the filename path component (public member function)[edit] | |
| returns the stem path component (public member function)[edit] | |
| returns the file extension path component (public member function)[edit] | |
Queries | |
| checks if the path is empty (public member function)[edit] | |
| checks if the corresponding path element is not empty (public member function)[edit] | |
| checks ifroot_path() uniquely identifies file system location (public member function)[edit] | |
Iterators | |
| iterator access to the path as a sequence of elements (public member function)[edit] | |
| swaps two paths (function)[edit] | |
| lexicographically compares two paths (function)[edit] | |
| concatenates two paths with a directory separator (function)[edit] | |
| performs stream input and output on a path (function)[edit] | |
creates apath from a UTF-8 encoded source(function)[edit] |