##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::experimental::filesystem::path

From cppreference.com
< cpp‎ | experimental‎ | fs

Defined in header `<experimental/filesystem>` |  |
class path; |  | (filesystem TS)

Objects of type `path` represent a path. Only syntactic aspects of paths are handled: the pathname may represent a non-existing path or even one that is not allowed on the current operating or file system.

The path can be traversed element-wise via iterators returned by the begin() and end() functions.

Calling any non-const member function of a `path` invalidates all iterators referring to elements of that object.

The forward traversal is done in the following order:

- The root name element, if any
- The root directory element, if any. The element is presented in generic format, thus lexicographical comparisons work correctly.
- Each successive filename element.
- `.` if one or mare trailing non-root `/` characters are present.

### [edit] Member types

Type | Definition
value_type | todo
string_type | std::basic_string<value_type>
iterator | a constant `BidirectionalIterator` with a `value_type` of `path`
const_iterator | todo

### [edit] Member constants

constexpr value_type preferred_separator [static] | todo (public static member constant)

### [edit] Member functions

(constructor) | constructs a `path` (public member function) [edit]
(destructor) | destroys a `path` object (public member function) [edit]
operator= | assigns another path (public member function) [edit]
assign | assigns contents (public member function) [edit]
##### Concatenation
append operator/= | appends elements to the path (public member function) [edit]
concat operator+= | concatenates two paths (public member function) [edit]
##### Modifiers
clear | erases the contents (public member function) [edit]
make_preferred | converts directory separators to preferred directory separator (public member function) [edit]
remove_filename | removes filename path component (public member function) [edit]
replace_filename | replaces the last path component with another path (public member function) [edit]
replace_extension | replaces the extension (public member function) [edit]
swap | swaps two paths (public member function) [edit]
##### Format observers
native operator string_type | returns the native version of the path (public member function) [edit]
c_str | returns the native version of the path (public member function) [edit]
string wstring u8string u16string u32string | returns the path in native pathname format converted to a string (public member function) [edit]
generic_string generic_wstring generic_u8string generic_u16string generic_u32string | returns the path in generic pathname format converted to a string (public member function) [edit]
##### Compare
compare | compares the lexical representations of two paths lexicographically (public member function) [edit]
##### Decomposition
root_name | returns the root-name of the path, if present (public member function) [edit]
root_directory | returns the root directory of the path, if present (public member function) [edit]
root_path | returns the root path of the path, if present (public member function) [edit]
relative_path | returns path relative to the root path (public member function) [edit]
parent_path | returns the path of the parent path (public member function) [edit]
filename | returns the filename path component (public member function) [edit]
stem | returns the stem path component (public member function) [edit]
extension | returns the file extension path component (public member function) [edit]
##### Queries
empty | checks if the path is empty (public member function) [edit]
has_root_path has_root_name has_root_directory has_relative_path has_parent_path has_filename has_stem has_extension | checks if the corresponding path element is not empty (public member function) [edit]
is_absolute is_relative | checks if root_path() uniquely identifies file system location (public member function) [edit]
##### Iterators
begin | returns an iterator to the beginning of element list (public member function) [edit]
end | returns an iterator to the end of element list (public member function) [edit]

### [edit] Non-member functions

swap(std::fs::path) | swaps two paths (function) [edit]
operator==operator!=operator<operator<=operator>operator>= | lexicographically compares two paths (function) [edit]
operator/ | concatenates two paths (function) [edit]
operator<<operator>> | performs stream input and output on a path (function) [edit]
u8path | creates a `path` from a UTF-8 encoded source (function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/experimental/fs/path&oldid=68577"