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path` <a id="fs.class.path">[[fs.class.path]]</a>
|
| 2 |
+
|
| 3 |
+
An object of class `path` represents a path ([[fs.def.path]]) and
|
| 4 |
+
contains a pathname ([[fs.def.pathname]]). Such an object is concerned
|
| 5 |
+
only with the lexical and syntactic aspects of a path. The path does not
|
| 6 |
+
necessarily exist in external storage, and the pathname is not
|
| 7 |
+
necessarily valid for the current operating system or for a particular
|
| 8 |
+
file system.
|
| 9 |
+
|
| 10 |
+
[*Note 1*: Class `path` is used to support the differences between the
|
| 11 |
+
string types used by different operating systems to represent pathnames,
|
| 12 |
+
and to perform conversions between encodings when
|
| 13 |
+
necessary. — *end note*]
|
| 14 |
+
|
| 15 |
+
``` cpp
|
| 16 |
+
namespace std::filesystem {
|
| 17 |
+
class path {
|
| 18 |
+
public:
|
| 19 |
+
using value_type = see below;
|
| 20 |
+
using string_type = basic_string<value_type>;
|
| 21 |
+
static constexpr value_type preferred_separator = see below;
|
| 22 |
+
|
| 23 |
+
// [fs.enum.path.format], enumeration format
|
| 24 |
+
enum format;
|
| 25 |
+
|
| 26 |
+
// [fs.path.construct], constructors and destructor
|
| 27 |
+
path() noexcept;
|
| 28 |
+
path(const path& p);
|
| 29 |
+
path(path&& p) noexcept;
|
| 30 |
+
path(string_type&& source, format fmt = auto_format);
|
| 31 |
+
template <class Source>
|
| 32 |
+
path(const Source& source, format fmt = auto_format);
|
| 33 |
+
template <class InputIterator>
|
| 34 |
+
path(InputIterator first, InputIterator last, format fmt = auto_format);
|
| 35 |
+
template <class Source>
|
| 36 |
+
path(const Source& source, const locale& loc, format fmt = auto_format);
|
| 37 |
+
template <class InputIterator>
|
| 38 |
+
path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format);
|
| 39 |
+
~path();
|
| 40 |
+
|
| 41 |
+
// [fs.path.assign], assignments
|
| 42 |
+
path& operator=(const path& p);
|
| 43 |
+
path& operator=(path&& p) noexcept;
|
| 44 |
+
path& operator=(string_type&& source);
|
| 45 |
+
path& assign(string_type&& source);
|
| 46 |
+
template <class Source>
|
| 47 |
+
path& operator=(const Source& source);
|
| 48 |
+
template <class Source>
|
| 49 |
+
path& assign(const Source& source)
|
| 50 |
+
template <class InputIterator>
|
| 51 |
+
path& assign(InputIterator first, InputIterator last);
|
| 52 |
+
|
| 53 |
+
// [fs.path.append], appends
|
| 54 |
+
path& operator/=(const path& p);
|
| 55 |
+
template <class Source>
|
| 56 |
+
path& operator/=(const Source& source);
|
| 57 |
+
template <class Source>
|
| 58 |
+
path& append(const Source& source);
|
| 59 |
+
template <class InputIterator>
|
| 60 |
+
path& append(InputIterator first, InputIterator last);
|
| 61 |
+
|
| 62 |
+
// [fs.path.concat], concatenation
|
| 63 |
+
path& operator+=(const path& x);
|
| 64 |
+
path& operator+=(const string_type& x);
|
| 65 |
+
path& operator+=(basic_string_view<value_type> x);
|
| 66 |
+
path& operator+=(const value_type* x);
|
| 67 |
+
path& operator+=(value_type x);
|
| 68 |
+
template <class Source>
|
| 69 |
+
path& operator+=(const Source& x);
|
| 70 |
+
template <class EcharT>
|
| 71 |
+
path& operator+=(EcharT x);
|
| 72 |
+
template <class Source>
|
| 73 |
+
path& concat(const Source& x);
|
| 74 |
+
template <class InputIterator>
|
| 75 |
+
path& concat(InputIterator first, InputIterator last);
|
| 76 |
+
|
| 77 |
+
// [fs.path.modifiers], modifiers
|
| 78 |
+
void clear() noexcept;
|
| 79 |
+
path& make_preferred();
|
| 80 |
+
path& remove_filename();
|
| 81 |
+
path& replace_filename(const path& replacement);
|
| 82 |
+
path& replace_extension(const path& replacement = path());
|
| 83 |
+
void swap(path& rhs) noexcept;
|
| 84 |
+
|
| 85 |
+
// [fs.path.native.obs], native format observers
|
| 86 |
+
const string_type& native() const noexcept;
|
| 87 |
+
const value_type* c_str() const noexcept;
|
| 88 |
+
operator string_type() const;
|
| 89 |
+
|
| 90 |
+
template <class EcharT, class traits = char_traits<EcharT>,
|
| 91 |
+
class Allocator = allocator<EcharT>>
|
| 92 |
+
basic_string<EcharT, traits, Allocator>
|
| 93 |
+
string(const Allocator& a = Allocator()) const;
|
| 94 |
+
std::string string() const;
|
| 95 |
+
std::wstring wstring() const;
|
| 96 |
+
std::string u8string() const;
|
| 97 |
+
std::u16string u16string() const;
|
| 98 |
+
std::u32string u32string() const;
|
| 99 |
+
|
| 100 |
+
// [fs.path.generic.obs], generic format observers
|
| 101 |
+
template <class EcharT, class traits = char_traits<EcharT>,
|
| 102 |
+
class Allocator = allocator<EcharT>>
|
| 103 |
+
basic_string<EcharT, traits, Allocator>
|
| 104 |
+
generic_string(const Allocator& a = Allocator()) const;
|
| 105 |
+
std::string generic_string() const;
|
| 106 |
+
std::wstring generic_wstring() const;
|
| 107 |
+
std::string generic_u8string() const;
|
| 108 |
+
std::u16string generic_u16string() const;
|
| 109 |
+
std::u32string generic_u32string() const;
|
| 110 |
+
|
| 111 |
+
// [fs.path.compare], compare
|
| 112 |
+
int compare(const path& p) const noexcept;
|
| 113 |
+
int compare(const string_type& s) const;
|
| 114 |
+
int compare(basic_string_view<value_type> s) const;
|
| 115 |
+
int compare(const value_type* s) const;
|
| 116 |
+
|
| 117 |
+
// [fs.path.decompose], decomposition
|
| 118 |
+
path root_name() const;
|
| 119 |
+
path root_directory() const;
|
| 120 |
+
path root_path() const;
|
| 121 |
+
path relative_path() const;
|
| 122 |
+
path parent_path() const;
|
| 123 |
+
path filename() const;
|
| 124 |
+
path stem() const;
|
| 125 |
+
path extension() const;
|
| 126 |
+
|
| 127 |
+
// [fs.path.query], query
|
| 128 |
+
bool empty() const noexcept;
|
| 129 |
+
bool has_root_name() const;
|
| 130 |
+
bool has_root_directory() const;
|
| 131 |
+
bool has_root_path() const;
|
| 132 |
+
bool has_relative_path() const;
|
| 133 |
+
bool has_parent_path() const;
|
| 134 |
+
bool has_filename() const;
|
| 135 |
+
bool has_stem() const;
|
| 136 |
+
bool has_extension() const;
|
| 137 |
+
bool is_absolute() const;
|
| 138 |
+
bool is_relative() const;
|
| 139 |
+
|
| 140 |
+
// [fs.path.gen], generation
|
| 141 |
+
path lexically_normal() const;
|
| 142 |
+
path lexically_relative(const path& base) const;
|
| 143 |
+
path lexically_proximate(const path& base) const;
|
| 144 |
+
|
| 145 |
+
// [fs.path.itr], iterators
|
| 146 |
+
class iterator;
|
| 147 |
+
using const_iterator = iterator;
|
| 148 |
+
|
| 149 |
+
iterator begin() const;
|
| 150 |
+
iterator end() const;
|
| 151 |
+
};
|
| 152 |
+
}
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
`value_type` is a `typedef` for the operating system dependent encoded
|
| 156 |
+
character type used to represent pathnames.
|
| 157 |
+
|
| 158 |
+
The value of the `preferred_separator` member is the operating system
|
| 159 |
+
dependent *preferred-separator* character ([[fs.path.generic]]).
|
| 160 |
+
|
| 161 |
+
[*Example 1*: For POSIX-based operating systems, `value_type` is `char`
|
| 162 |
+
and `preferred_separator` is the slash character (`'/'`). For
|
| 163 |
+
Windows-based operating systems, `value_type` is `wchar_t` and
|
| 164 |
+
`preferred_separator` is the backslash character
|
| 165 |
+
(`L'\\'`). — *end example*]
|
| 166 |
+
|
| 167 |
+
#### Generic pathname format <a id="fs.path.generic">[[fs.path.generic]]</a>
|
| 168 |
+
|
| 169 |
+
``` bnf
|
| 170 |
+
pathname:
|
| 171 |
+
root-nameₒₚₜ root-directoryₒₚₜ relative-path
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
``` bnf
|
| 175 |
+
root-name:
|
| 176 |
+
operating system dependent sequences of characters
|
| 177 |
+
implementation-defined sequences of characters
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
``` bnf
|
| 181 |
+
root-directory:
|
| 182 |
+
directory-separator
|
| 183 |
+
```
|
| 184 |
+
|
| 185 |
+
``` bnf
|
| 186 |
+
relative-path:
|
| 187 |
+
filename
|
| 188 |
+
filename directory-separator relative-path
|
| 189 |
+
an empty path
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
``` bnf
|
| 193 |
+
filename:
|
| 194 |
+
non-empty sequence of characters other than *directory-separator* characters
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
``` bnf
|
| 198 |
+
directory-separator:
|
| 199 |
+
preferred-separator directory-separatorₒₚₜ
|
| 200 |
+
fallback-separator directory-separatorₒₚₜ
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
``` bnf
|
| 204 |
+
preferred-separator:
|
| 205 |
+
operating system dependent directory separator character
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
``` bnf
|
| 209 |
+
fallback-separator:
|
| 210 |
+
/, if *preferred-separator* is not /
|
| 211 |
+
```
|
| 212 |
+
|
| 213 |
+
[*Note 1*: Operating systems often place restrictions on the characters
|
| 214 |
+
that may be used in a *filename*. For wide portability, users may wish
|
| 215 |
+
to limit *filename* characters to the POSIX Portable Filename Character
|
| 216 |
+
Set:
|
| 217 |
+
`A B C D E F G H I J K L M N O P Q R S T U V W X Y Z`
|
| 218 |
+
`a b c d e f g h i j k l m n o p q r s t u v w x y z`
|
| 219 |
+
`0 1 2 3 4 5 6 7 8 9 . _ -` — *end note*]
|
| 220 |
+
|
| 221 |
+
Except in a *root-name*, multiple successive *directory-separator*
|
| 222 |
+
characters are considered to be the same as one *directory-separator*
|
| 223 |
+
character.
|
| 224 |
+
|
| 225 |
+
The filename *dot* ([[fs.def.filename]]) is treated as a reference to
|
| 226 |
+
the current directory. The filename *dot-dot* ([[fs.def.filename]]) is
|
| 227 |
+
treated as a reference to the parent directory. What the filename
|
| 228 |
+
*dot-dot* refers to relative to *root-directory* is
|
| 229 |
+
*implementation-defined*. Specific filenames may have special meanings
|
| 230 |
+
for a particular operating system.
|
| 231 |
+
|
| 232 |
+
A *root-name* identifies the starting location for pathname resolution (
|
| 233 |
+
[[fs.def.pathres]]). If there are no operating system dependent
|
| 234 |
+
*root-name*s, at least one *implementation-defined* *root-name* is
|
| 235 |
+
required.
|
| 236 |
+
|
| 237 |
+
[*Note 2*: Many operating systems define a name beginning with two
|
| 238 |
+
*directory-separator* characters as a *root-name* that identifies
|
| 239 |
+
network or other resource locations. Some operating systems define a
|
| 240 |
+
single letter followed by a colon as a drive specifier – a *root-name*
|
| 241 |
+
identifying a specific device such as a disk drive. — *end note*]
|
| 242 |
+
|
| 243 |
+
If a *root-name* is otherwise ambiguous, the possibility with the
|
| 244 |
+
longest sequence of characters is chosen.
|
| 245 |
+
|
| 246 |
+
[*Note 3*: On a POSIX-like operating system, it is impossible to have a
|
| 247 |
+
*root-name* and a *relative-path* without an intervening
|
| 248 |
+
*root-directory* element. — *end note*]
|
| 249 |
+
|
| 250 |
+
#### `path` conversions <a id="fs.path.cvt">[[fs.path.cvt]]</a>
|
| 251 |
+
|
| 252 |
+
##### `path` argument format conversions <a id="fs.path.fmt.cvt">[[fs.path.fmt.cvt]]</a>
|
| 253 |
+
|
| 254 |
+
[*Note 1*:
|
| 255 |
+
|
| 256 |
+
The format conversions described in this section are not applied on
|
| 257 |
+
POSIX-based operating systems because on these systems:
|
| 258 |
+
|
| 259 |
+
- The generic format is acceptable as a native path.
|
| 260 |
+
- There is no need to distinguish between native format and generic
|
| 261 |
+
format in function arguments.
|
| 262 |
+
- Paths for regular files and paths for directories share the same
|
| 263 |
+
syntax.
|
| 264 |
+
|
| 265 |
+
— *end note*]
|
| 266 |
+
|
| 267 |
+
Several functions are defined to accept *detected-format* arguments,
|
| 268 |
+
which are character sequences. A detected-format argument represents a
|
| 269 |
+
path using either a pathname in the generic format (
|
| 270 |
+
[[fs.path.generic]]) or a pathname in the native format (
|
| 271 |
+
[[fs.def.native]]). Such an argument is taken to be in the generic
|
| 272 |
+
format if and only if it matches the generic format and is not
|
| 273 |
+
acceptable to the operating system as a native path.
|
| 274 |
+
|
| 275 |
+
[*Note 2*: Some operating systems may have no unambiguous way to
|
| 276 |
+
distinguish between native format and generic format arguments. This is
|
| 277 |
+
by design as it simplifies use for operating systems that do not require
|
| 278 |
+
disambiguation. An implementation for an operating system where
|
| 279 |
+
disambiguation is required is permitted to distinguish between the
|
| 280 |
+
formats. — *end note*]
|
| 281 |
+
|
| 282 |
+
Pathnames are converted as needed between the generic and native formats
|
| 283 |
+
in an operating-system-dependent manner. Let *G(n)* and *N(g)* in a
|
| 284 |
+
mathematical sense be the implementation’s functions that convert
|
| 285 |
+
native-to-generic and generic-to-native formats respectively. If
|
| 286 |
+
*g=G(n)* for some *n*, then *G(N(g))=g*; if *n=N(g)* for some *g*, then
|
| 287 |
+
*N(G(n))=n*.
|
| 288 |
+
|
| 289 |
+
[*Note 3*: Neither *G* nor *N* need be invertible. — *end note*]
|
| 290 |
+
|
| 291 |
+
If the native format requires paths for regular files to be formatted
|
| 292 |
+
differently from paths for directories, the path shall be treated as a
|
| 293 |
+
directory path if its last element is a *directory-separator*, otherwise
|
| 294 |
+
it shall be treated as a path to a regular file.
|
| 295 |
+
|
| 296 |
+
[*Note 4*: A path stores a native format pathname (
|
| 297 |
+
[[fs.path.native.obs]]) and acts as if it also stores a generic format
|
| 298 |
+
pathname, related as given below. The implementation may generate the
|
| 299 |
+
generic format pathname based on the native format pathname (and
|
| 300 |
+
possibly other information) when requested. — *end note*]
|
| 301 |
+
|
| 302 |
+
When a path is constructed from or is assigned a single representation
|
| 303 |
+
separate from any path, the other representation is selected by the
|
| 304 |
+
appropriate conversion function (*G* or *N*).
|
| 305 |
+
|
| 306 |
+
When the (new) value *p* of one representation of a path is derived from
|
| 307 |
+
the representation of that or another path, a value *q* is chosen for
|
| 308 |
+
the other representation. The value *q* converts to *p* (by *G* or *N*
|
| 309 |
+
as appropriate) if any such value does so; *q* is otherwise unspecified.
|
| 310 |
+
|
| 311 |
+
[*Note 5*: If *q* is the result of converting any path at all, it is
|
| 312 |
+
the result of converting *p*. — *end note*]
|
| 313 |
+
|
| 314 |
+
##### `path` type and encoding conversions <a id="fs.path.type.cvt">[[fs.path.type.cvt]]</a>
|
| 315 |
+
|
| 316 |
+
For member function arguments that take character sequences representing
|
| 317 |
+
paths and for member functions returning strings, value type and
|
| 318 |
+
encoding conversion is performed if the value type of the argument or
|
| 319 |
+
return value differs from `path::value_type`. For the argument or return
|
| 320 |
+
value, the method of conversion and the encoding to be converted to is
|
| 321 |
+
determined by its value type:
|
| 322 |
+
|
| 323 |
+
- `char`: The encoding is the native narrow encoding (
|
| 324 |
+
[[fs.def.native.encode]]). The method of conversion, if any, is
|
| 325 |
+
operating system dependent. \[*Note 6*: For POSIX-based operating
|
| 326 |
+
systems `path::value_type` is `char` so no conversion from `char`
|
| 327 |
+
value type arguments or to `char` value type return values is
|
| 328 |
+
performed. For Windows-based operating systems, the native narrow
|
| 329 |
+
encoding is determined by calling a Windows API
|
| 330 |
+
function. — *end note*] \[*Note 7*: This results in behavior
|
| 331 |
+
identical to other C and C++ standard library functions that perform
|
| 332 |
+
file operations using narrow character strings to identify paths.
|
| 333 |
+
Changing this behavior would be surprising and error
|
| 334 |
+
prone. — *end note*]
|
| 335 |
+
- `wchar_t`: The encoding is the native wide encoding (
|
| 336 |
+
[[fs.def.native.encode]]). The method of conversion is unspecified.
|
| 337 |
+
\[*Note 8*: For Windows-based operating systems `path::value_type` is
|
| 338 |
+
`wchar_t` so no conversion from `wchar_t` value type arguments or to
|
| 339 |
+
`wchar_t` value type return values is performed. — *end note*]
|
| 340 |
+
- `char16_t`: The encoding is UTF-16. The method of conversion is
|
| 341 |
+
unspecified.
|
| 342 |
+
- `char32_t`: The encoding is UTF-32. The method of conversion is
|
| 343 |
+
unspecified.
|
| 344 |
+
|
| 345 |
+
If the encoding being converted to has no representation for source
|
| 346 |
+
characters, the resulting converted characters, if any, are unspecified.
|
| 347 |
+
Implementations should not modify member function arguments if already
|
| 348 |
+
of type `path::value_type`.
|
| 349 |
+
|
| 350 |
+
#### `path` requirements <a id="fs.path.req">[[fs.path.req]]</a>
|
| 351 |
+
|
| 352 |
+
In addition to the requirements ([[fs.req]]), function template
|
| 353 |
+
parameters named `Source` shall be one of:
|
| 354 |
+
|
| 355 |
+
- `basic_string<EcharT, traits, Allocator>`. A function argument
|
| 356 |
+
`const Source&` `source` shall have an effective range
|
| 357 |
+
\[`source.begin()`, `source.end()`).
|
| 358 |
+
- `basic_string_view<EcharT, traits>`. A function argument
|
| 359 |
+
`const Source&` `source` shall have an effective range
|
| 360 |
+
\[`source.begin()`, `source.end()`).
|
| 361 |
+
- A type meeting the input iterator requirements that iterates over a
|
| 362 |
+
NTCTS. The value type shall be an encoded character type. A function
|
| 363 |
+
argument `const Source&` `source` shall have an effective range
|
| 364 |
+
\[`source`, `end`) where `end` is the first iterator value with an
|
| 365 |
+
element value equal to `iterator_traits<Source>::value_type()`.
|
| 366 |
+
- A character array that after array-to-pointer decay results in a
|
| 367 |
+
pointer to the start of a NTCTS. The value type shall be an encoded
|
| 368 |
+
character type. A function argument `const Source&` `source` shall
|
| 369 |
+
have an effective range \[`source`, `end`) where `end` is the first
|
| 370 |
+
iterator value with an element value equal to
|
| 371 |
+
`iterator_traits<decay_t<Source>>::value_type()`.
|
| 372 |
+
|
| 373 |
+
Functions taking template parameters named `Source` shall not
|
| 374 |
+
participate in overload resolution unless either
|
| 375 |
+
|
| 376 |
+
- `Source` is a specialization of `basic_string` or `basic_string_view`,
|
| 377 |
+
or
|
| 378 |
+
- the *qualified-id* `iterator_traits<decay_t<Source>>::value_type` is
|
| 379 |
+
valid and denotes a possibly `const` encoded character type (
|
| 380 |
+
[[temp.deduct]]).
|
| 381 |
+
|
| 382 |
+
[*Note 1*: See path conversions ([[fs.path.cvt]]) for how the value
|
| 383 |
+
types above and their encodings convert to `path::value_type` and its
|
| 384 |
+
encoding. — *end note*]
|
| 385 |
+
|
| 386 |
+
Arguments of type `Source` shall not be null pointers.
|
| 387 |
+
|
| 388 |
+
#### `path` members <a id="fs.path.member">[[fs.path.member]]</a>
|
| 389 |
+
|
| 390 |
+
##### `path` constructors <a id="fs.path.construct">[[fs.path.construct]]</a>
|
| 391 |
+
|
| 392 |
+
``` cpp
|
| 393 |
+
path() noexcept;
|
| 394 |
+
```
|
| 395 |
+
|
| 396 |
+
*Effects:* Constructs an object of class `path`.
|
| 397 |
+
|
| 398 |
+
*Postconditions:* `empty() == true`.
|
| 399 |
+
|
| 400 |
+
``` cpp
|
| 401 |
+
path(const path& p);
|
| 402 |
+
path(path&& p) noexcept;
|
| 403 |
+
```
|
| 404 |
+
|
| 405 |
+
*Effects:* Constructs an object of class `path` having the same pathname
|
| 406 |
+
in the native and generic formats, respectively, as the original value
|
| 407 |
+
of `p`. In the second form, `p` is left in a valid but unspecified
|
| 408 |
+
state.
|
| 409 |
+
|
| 410 |
+
``` cpp
|
| 411 |
+
path(string_type&& source, format fmt = auto_format);
|
| 412 |
+
```
|
| 413 |
+
|
| 414 |
+
*Effects:* Constructs an object of class `path` for which the pathname
|
| 415 |
+
in the detected-format of `source` has the original value of
|
| 416 |
+
`source` ([[fs.path.fmt.cvt]]), converting format if
|
| 417 |
+
required ([[fs.path.fmt.cvt]]). `source` is left in a valid but
|
| 418 |
+
unspecified state.
|
| 419 |
+
|
| 420 |
+
``` cpp
|
| 421 |
+
template <class Source>
|
| 422 |
+
path(const Source& source, format fmt = auto_format);
|
| 423 |
+
template <class InputIterator>
|
| 424 |
+
path(InputIterator first, InputIterator last, format fmt = auto_format);
|
| 425 |
+
```
|
| 426 |
+
|
| 427 |
+
*Effects:* Let `s` be the effective range of `source` ([[fs.path.req]])
|
| 428 |
+
or the range \[`first`, `last`), with the encoding converted if
|
| 429 |
+
required ([[fs.path.cvt]]). Finds the detected-format of
|
| 430 |
+
`s` ([[fs.path.fmt.cvt]]) and constructs an object of class `path` for
|
| 431 |
+
which the pathname in that format is `s`.
|
| 432 |
+
|
| 433 |
+
``` cpp
|
| 434 |
+
template <class Source>
|
| 435 |
+
path(const Source& source, const locale& loc, format fmt = auto_format);
|
| 436 |
+
template <class InputIterator>
|
| 437 |
+
path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format);
|
| 438 |
+
```
|
| 439 |
+
|
| 440 |
+
*Requires:* The value type of `Source` and `InputIterator` is `char`.
|
| 441 |
+
|
| 442 |
+
*Effects:* Let `s` be the effective range of `source` or the range
|
| 443 |
+
\[`first`, `last`), after converting the encoding as follows:
|
| 444 |
+
|
| 445 |
+
- If `value_type` is `wchar_t`, converts to the native wide
|
| 446 |
+
encoding ([[fs.def.native.encode]]) using the
|
| 447 |
+
`codecvt<wchar_t, char, mbstate_t>` facet of `loc`.
|
| 448 |
+
- Otherwise a conversion is performed using the
|
| 449 |
+
`codecvt<wchar_t, char, mbstate_t>` facet of `loc`, and then a second
|
| 450 |
+
conversion to the current narrow encoding.
|
| 451 |
+
|
| 452 |
+
Finds the detected-format of `s` ([[fs.path.fmt.cvt]]) and constructs
|
| 453 |
+
an object of class `path` for which the pathname in that format is `s`.
|
| 454 |
+
|
| 455 |
+
[*Example 1*:
|
| 456 |
+
|
| 457 |
+
A string is to be read from a database that is encoded in ISO/IEC
|
| 458 |
+
8859-1, and used to create a directory:
|
| 459 |
+
|
| 460 |
+
``` cpp
|
| 461 |
+
namespace fs = std::filesystem;
|
| 462 |
+
std::string latin1_string = read_latin1_data();
|
| 463 |
+
codecvt_8859_1<wchar_t> latin1_facet;
|
| 464 |
+
std::locale latin1_locale(std::locale(), latin1_facet);
|
| 465 |
+
fs::create_directory(fs::path(latin1_string, latin1_locale));
|
| 466 |
+
```
|
| 467 |
+
|
| 468 |
+
For POSIX-based operating systems, the path is constructed by first
|
| 469 |
+
using `latin1_facet` to convert ISO/IEC 8859-1 encoded `latin1_string`
|
| 470 |
+
to a wide character string in the native wide
|
| 471 |
+
encoding ([[fs.def.native.encode]]). The resulting wide string is then
|
| 472 |
+
converted to a narrow character pathname string in the current native
|
| 473 |
+
narrow encoding. If the native wide encoding is UTF-16 or UTF-32, and
|
| 474 |
+
the current native narrow encoding is UTF-8, all of the characters in
|
| 475 |
+
the ISO/IEC 8859-1 character set will be converted to their Unicode
|
| 476 |
+
representation, but for other native narrow encodings some characters
|
| 477 |
+
may have no representation.
|
| 478 |
+
|
| 479 |
+
For Windows-based operating systems, the path is constructed by using
|
| 480 |
+
`latin1_facet` to convert ISO/IEC 8859-1 encoded `latin1_string` to a
|
| 481 |
+
UTF-16 encoded wide character pathname string. All of the characters in
|
| 482 |
+
the ISO/IEC 8859-1 character set will be converted to their Unicode
|
| 483 |
+
representation.
|
| 484 |
+
|
| 485 |
+
— *end example*]
|
| 486 |
+
|
| 487 |
+
##### `path` assignments <a id="fs.path.assign">[[fs.path.assign]]</a>
|
| 488 |
+
|
| 489 |
+
``` cpp
|
| 490 |
+
path& operator=(const path& p);
|
| 491 |
+
```
|
| 492 |
+
|
| 493 |
+
*Effects:* If `*this` and `p` are the same object, has no effect.
|
| 494 |
+
Otherwise, sets both respective pathnames of `*this` to the respective
|
| 495 |
+
pathnames of `p`.
|
| 496 |
+
|
| 497 |
+
*Returns:* `*this`.
|
| 498 |
+
|
| 499 |
+
``` cpp
|
| 500 |
+
path& operator=(path&& p) noexcept;
|
| 501 |
+
```
|
| 502 |
+
|
| 503 |
+
*Effects:* If `*this` and `p` are the same object, has no effect.
|
| 504 |
+
Otherwise, sets both respective pathnames of `*this` to the respective
|
| 505 |
+
pathnames of `p`. `p` is left in a valid but unspecified state.
|
| 506 |
+
|
| 507 |
+
[*Note 1*: A valid implementation is `swap(p)`. — *end note*]
|
| 508 |
+
|
| 509 |
+
*Returns:* `*this`.
|
| 510 |
+
|
| 511 |
+
``` cpp
|
| 512 |
+
path& operator=(string_type&& source);
|
| 513 |
+
path& assign(string_type&& source);
|
| 514 |
+
```
|
| 515 |
+
|
| 516 |
+
*Effects:* Sets the pathname in the detected-format of `source` to the
|
| 517 |
+
original value of `source`. `source` is left in a valid but unspecified
|
| 518 |
+
state.
|
| 519 |
+
|
| 520 |
+
*Returns:* `*this`.
|
| 521 |
+
|
| 522 |
+
``` cpp
|
| 523 |
+
template <class Source>
|
| 524 |
+
path& operator=(const Source& source);
|
| 525 |
+
template <class Source>
|
| 526 |
+
path& assign(const Source& source);
|
| 527 |
+
template <class InputIterator>
|
| 528 |
+
path& assign(InputIterator first, InputIterator last);
|
| 529 |
+
```
|
| 530 |
+
|
| 531 |
+
*Effects:* Let `s` be the effective range of `source` ([[fs.path.req]])
|
| 532 |
+
or the range \[`first`, `last`), with the encoding converted if
|
| 533 |
+
required ([[fs.path.cvt]]). Finds the detected-format of
|
| 534 |
+
`s` ([[fs.path.fmt.cvt]]) and sets the pathname in that format to `s`.
|
| 535 |
+
|
| 536 |
+
*Returns:* `*this`.
|
| 537 |
+
|
| 538 |
+
##### `path` appends <a id="fs.path.append">[[fs.path.append]]</a>
|
| 539 |
+
|
| 540 |
+
The append operations use `operator/=` to denote their semantic effect
|
| 541 |
+
of appending *preferred-separator* when needed.
|
| 542 |
+
|
| 543 |
+
``` cpp
|
| 544 |
+
path& operator/=(const path& p);
|
| 545 |
+
```
|
| 546 |
+
|
| 547 |
+
*Effects:* If
|
| 548 |
+
`p.is_absolute() || (p.has_root_name() && p.root_name() != root_name())`,
|
| 549 |
+
then `operator=(p)`.
|
| 550 |
+
|
| 551 |
+
Otherwise, modifies `*this` as if by these steps:
|
| 552 |
+
|
| 553 |
+
- If `p.has_root_directory()`, then removes any root directory and
|
| 554 |
+
relative path from the generic format pathname. Otherwise, if
|
| 555 |
+
`!has_root_directory() && is_absolute()` is `true` or if
|
| 556 |
+
`has_filename()` is `true`, then appends `path::preferred_separator`
|
| 557 |
+
to the generic format pathname.
|
| 558 |
+
- Then appends the native format pathname of `p`, omitting any
|
| 559 |
+
*root-name* from its generic format pathname, to the native format
|
| 560 |
+
pathname.
|
| 561 |
+
|
| 562 |
+
[*Example 2*:
|
| 563 |
+
|
| 564 |
+
Even if `//host` is interpreted as a *root-name*, both of the paths
|
| 565 |
+
`path("//host")/"foo"` and `path("//host/")/"foo"` equal `"//host/foo"`.
|
| 566 |
+
|
| 567 |
+
Expression examples:
|
| 568 |
+
|
| 569 |
+
``` cpp
|
| 570 |
+
// On POSIX,
|
| 571 |
+
path("foo") / ""; // yields "foo/"
|
| 572 |
+
path("foo") / "/bar"; // yields "/bar"
|
| 573 |
+
// On Windows, backslashes replace slashes in the above yields
|
| 574 |
+
|
| 575 |
+
// On Windows,
|
| 576 |
+
path("foo") / "c:/bar"; // yields "c:/bar"
|
| 577 |
+
path("foo") / "c:"; // yields "c:"
|
| 578 |
+
path("c:") / ""; // yields "c:"
|
| 579 |
+
path("c:foo") / "/bar"; // yields "c:/bar"
|
| 580 |
+
path("c:foo") / "c:bar"; // yields "c:foo/bar"
|
| 581 |
+
```
|
| 582 |
+
|
| 583 |
+
— *end example*]
|
| 584 |
+
|
| 585 |
+
*Returns:* `*this`.
|
| 586 |
+
|
| 587 |
+
``` cpp
|
| 588 |
+
template <class Source>
|
| 589 |
+
path& operator/=(const Source& source);
|
| 590 |
+
template <class Source>
|
| 591 |
+
path& append(const Source& source);
|
| 592 |
+
```
|
| 593 |
+
|
| 594 |
+
*Effects:* Equivalent to: `return operator/=(path(source));`
|
| 595 |
+
|
| 596 |
+
``` cpp
|
| 597 |
+
template <class InputIterator>
|
| 598 |
+
path& append(InputIterator first, InputIterator last);
|
| 599 |
+
```
|
| 600 |
+
|
| 601 |
+
*Effects:* Equivalent to: `return operator/=(path(first, last));`
|
| 602 |
+
|
| 603 |
+
##### `path` concatenation <a id="fs.path.concat">[[fs.path.concat]]</a>
|
| 604 |
+
|
| 605 |
+
``` cpp
|
| 606 |
+
path& operator+=(const path& x);
|
| 607 |
+
path& operator+=(const string_type& x);
|
| 608 |
+
path& operator+=(basic_string_view<value_type> x);
|
| 609 |
+
path& operator+=(const value_type* x);
|
| 610 |
+
path& operator+=(value_type x);
|
| 611 |
+
template <class Source>
|
| 612 |
+
path& operator+=(const Source& x);
|
| 613 |
+
template <class EcharT>
|
| 614 |
+
path& operator+=(EcharT x);
|
| 615 |
+
template <class Source>
|
| 616 |
+
path& concat(const Source& x);
|
| 617 |
+
```
|
| 618 |
+
|
| 619 |
+
*Effects:* Appends `path(x).native()` to the pathname in the native
|
| 620 |
+
format.
|
| 621 |
+
|
| 622 |
+
[*Note 2*: This directly manipulates the value of `native()` and may
|
| 623 |
+
not be portable between operating systems. — *end note*]
|
| 624 |
+
|
| 625 |
+
*Returns:* `*this`.
|
| 626 |
+
|
| 627 |
+
``` cpp
|
| 628 |
+
template <class InputIterator>
|
| 629 |
+
path& concat(InputIterator first, InputIterator last);
|
| 630 |
+
```
|
| 631 |
+
|
| 632 |
+
*Effects:* Equivalent to `return *this += path(first, last)`.
|
| 633 |
+
|
| 634 |
+
##### `path` modifiers <a id="fs.path.modifiers">[[fs.path.modifiers]]</a>
|
| 635 |
+
|
| 636 |
+
``` cpp
|
| 637 |
+
void clear() noexcept;
|
| 638 |
+
```
|
| 639 |
+
|
| 640 |
+
*Postconditions:* `empty() == true`.
|
| 641 |
+
|
| 642 |
+
``` cpp
|
| 643 |
+
path& make_preferred();
|
| 644 |
+
```
|
| 645 |
+
|
| 646 |
+
*Effects:* Each *directory-separator* of the pathname in the generic
|
| 647 |
+
format is converted to *preferred-separator*.
|
| 648 |
+
|
| 649 |
+
*Returns:* `*this`.
|
| 650 |
+
|
| 651 |
+
[*Example 3*:
|
| 652 |
+
|
| 653 |
+
``` cpp
|
| 654 |
+
path p("foo/bar");
|
| 655 |
+
std::cout << p << '\n';
|
| 656 |
+
p.make_preferred();
|
| 657 |
+
std::cout << p << '\n';
|
| 658 |
+
```
|
| 659 |
+
|
| 660 |
+
On an operating system where *preferred-separator* is a slash, the
|
| 661 |
+
output is:
|
| 662 |
+
|
| 663 |
+
``` cpp
|
| 664 |
+
"foo/bar"
|
| 665 |
+
"foo/bar"
|
| 666 |
+
```
|
| 667 |
+
|
| 668 |
+
On an operating system where *preferred-separator* is a backslash, the
|
| 669 |
+
output is:
|
| 670 |
+
|
| 671 |
+
``` cpp
|
| 672 |
+
"foo/bar"
|
| 673 |
+
"foo\bar"
|
| 674 |
+
```
|
| 675 |
+
|
| 676 |
+
— *end example*]
|
| 677 |
+
|
| 678 |
+
``` cpp
|
| 679 |
+
path& remove_filename();
|
| 680 |
+
```
|
| 681 |
+
|
| 682 |
+
*Postconditions:* `!has_filename()`.
|
| 683 |
+
|
| 684 |
+
*Effects:* Remove the generic format pathname of `filename()` from the
|
| 685 |
+
generic format pathname.
|
| 686 |
+
|
| 687 |
+
*Returns:* `*this`.
|
| 688 |
+
|
| 689 |
+
[*Example 4*:
|
| 690 |
+
|
| 691 |
+
``` cpp
|
| 692 |
+
path("foo/bar").remove_filename(); // yields "foo/"
|
| 693 |
+
path("foo/").remove_filename(); // yields "foo/"
|
| 694 |
+
path("/foo").remove_filename(); // yields "/"
|
| 695 |
+
path("/").remove_filename(); // yields "/"
|
| 696 |
+
```
|
| 697 |
+
|
| 698 |
+
— *end example*]
|
| 699 |
+
|
| 700 |
+
``` cpp
|
| 701 |
+
path& replace_filename(const path& replacement);
|
| 702 |
+
```
|
| 703 |
+
|
| 704 |
+
*Effects:* Equivalent to:
|
| 705 |
+
|
| 706 |
+
``` cpp
|
| 707 |
+
remove_filename();
|
| 708 |
+
operator/=(replacement);
|
| 709 |
+
```
|
| 710 |
+
|
| 711 |
+
*Returns:* `*this`.
|
| 712 |
+
|
| 713 |
+
[*Example 5*:
|
| 714 |
+
|
| 715 |
+
``` cpp
|
| 716 |
+
path("/foo").replace_filename("bar"); // yields "/bar" on POSIX
|
| 717 |
+
path("/").replace_filename("bar"); // yields "/bar" on POSIX
|
| 718 |
+
```
|
| 719 |
+
|
| 720 |
+
— *end example*]
|
| 721 |
+
|
| 722 |
+
``` cpp
|
| 723 |
+
path& replace_extension(const path& replacement = path());
|
| 724 |
+
```
|
| 725 |
+
|
| 726 |
+
*Effects:*
|
| 727 |
+
|
| 728 |
+
- Any existing `extension()(` [[fs.path.decompose]]`)` is removed from
|
| 729 |
+
the pathname in the generic format, then
|
| 730 |
+
- If `replacement` is not empty and does not begin with a dot character,
|
| 731 |
+
a dot character is appended to the pathname in the generic format,
|
| 732 |
+
then
|
| 733 |
+
- `operator+=(replacement);`.
|
| 734 |
+
|
| 735 |
+
*Returns:* `*this`.
|
| 736 |
+
|
| 737 |
+
``` cpp
|
| 738 |
+
void swap(path& rhs) noexcept;
|
| 739 |
+
```
|
| 740 |
+
|
| 741 |
+
*Effects:* Swaps the contents (in all formats) of the two paths.
|
| 742 |
+
|
| 743 |
+
*Complexity:* Constant time.
|
| 744 |
+
|
| 745 |
+
##### `path` native format observers <a id="fs.path.native.obs">[[fs.path.native.obs]]</a>
|
| 746 |
+
|
| 747 |
+
The string returned by all native format observers is in the native
|
| 748 |
+
pathname format ([[fs.def.native]]).
|
| 749 |
+
|
| 750 |
+
``` cpp
|
| 751 |
+
const string_type& native() const noexcept;
|
| 752 |
+
```
|
| 753 |
+
|
| 754 |
+
*Returns:* The pathname in the native format.
|
| 755 |
+
|
| 756 |
+
``` cpp
|
| 757 |
+
const value_type* c_str() const noexcept;
|
| 758 |
+
```
|
| 759 |
+
|
| 760 |
+
*Returns:* Equivalent to `native().c_str()`.
|
| 761 |
+
|
| 762 |
+
``` cpp
|
| 763 |
+
operator string_type() const;
|
| 764 |
+
```
|
| 765 |
+
|
| 766 |
+
*Returns:* `native()`.
|
| 767 |
+
|
| 768 |
+
[*Note 3*: Conversion to `string_type` is provided so that an object of
|
| 769 |
+
class `path` can be given as an argument to existing standard library
|
| 770 |
+
file stream constructors and open functions. — *end note*]
|
| 771 |
+
|
| 772 |
+
``` cpp
|
| 773 |
+
template <class EcharT, class traits = char_traits<EcharT>,
|
| 774 |
+
class Allocator = allocator<EcharT>>
|
| 775 |
+
basic_string<EcharT, traits, Allocator>
|
| 776 |
+
string(const Allocator& a = Allocator()) const;
|
| 777 |
+
```
|
| 778 |
+
|
| 779 |
+
*Returns:* `native()`.
|
| 780 |
+
|
| 781 |
+
*Remarks:* All memory allocation, including for the return value, shall
|
| 782 |
+
be performed by `a`. Conversion, if any, is specified by
|
| 783 |
+
[[fs.path.cvt]].
|
| 784 |
+
|
| 785 |
+
``` cpp
|
| 786 |
+
std::string string() const;
|
| 787 |
+
std::wstring wstring() const;
|
| 788 |
+
std::string u8string() const;
|
| 789 |
+
std::u16string u16string() const;
|
| 790 |
+
std::u32string u32string() const;
|
| 791 |
+
```
|
| 792 |
+
|
| 793 |
+
*Returns:* `pathstring`.
|
| 794 |
+
|
| 795 |
+
*Remarks:* Conversion, if any, is performed as specified by
|
| 796 |
+
[[fs.path.cvt]]. The encoding of the string returned by `u8string()` is
|
| 797 |
+
always UTF-8.
|
| 798 |
+
|
| 799 |
+
##### `path` generic format observers <a id="fs.path.generic.obs">[[fs.path.generic.obs]]</a>
|
| 800 |
+
|
| 801 |
+
Generic format observer functions return strings formatted according to
|
| 802 |
+
the generic pathname format ([[fs.path.generic]]). A single slash
|
| 803 |
+
(`'/'`) character is used as the *directory-separator*.
|
| 804 |
+
|
| 805 |
+
[*Example 1*:
|
| 806 |
+
|
| 807 |
+
On an operating system that uses backslash as its *preferred-separator*,
|
| 808 |
+
|
| 809 |
+
``` cpp
|
| 810 |
+
path("foo\\bar").generic_string()
|
| 811 |
+
```
|
| 812 |
+
|
| 813 |
+
returns `"foo/bar"`.
|
| 814 |
+
|
| 815 |
+
— *end example*]
|
| 816 |
+
|
| 817 |
+
``` cpp
|
| 818 |
+
template <class EcharT, class traits = char_traits<EcharT>,
|
| 819 |
+
class Allocator = allocator<EcharT>>
|
| 820 |
+
basic_string<EcharT, traits, Allocator>
|
| 821 |
+
generic_string(const Allocator& a = Allocator()) const;
|
| 822 |
+
```
|
| 823 |
+
|
| 824 |
+
*Returns:* The pathname in the generic format.
|
| 825 |
+
|
| 826 |
+
*Remarks:* All memory allocation, including for the return value, shall
|
| 827 |
+
be performed by `a`. Conversion, if any, is specified by
|
| 828 |
+
[[fs.path.cvt]].
|
| 829 |
+
|
| 830 |
+
``` cpp
|
| 831 |
+
std::string generic_string() const;
|
| 832 |
+
std::wstring generic_wstring() const;
|
| 833 |
+
std::string generic_u8string() const;
|
| 834 |
+
std::u16string generic_u16string() const;
|
| 835 |
+
std::u32string generic_u32string() const;
|
| 836 |
+
```
|
| 837 |
+
|
| 838 |
+
*Returns:* The pathname in the generic format.
|
| 839 |
+
|
| 840 |
+
*Remarks:* Conversion, if any, is specified by [[fs.path.cvt]]. The
|
| 841 |
+
encoding of the string returned by `generic_u8string()` is always UTF-8.
|
| 842 |
+
|
| 843 |
+
##### `path` compare <a id="fs.path.compare">[[fs.path.compare]]</a>
|
| 844 |
+
|
| 845 |
+
``` cpp
|
| 846 |
+
int compare(const path& p) const noexcept;
|
| 847 |
+
```
|
| 848 |
+
|
| 849 |
+
*Returns:*
|
| 850 |
+
|
| 851 |
+
- A value less than `0`, if `native()` for the elements of `*this` are
|
| 852 |
+
lexicographically less than `native()` for the elements of `p`;
|
| 853 |
+
otherwise,
|
| 854 |
+
- a value greater than `0`, if `native()` for the elements of `*this`
|
| 855 |
+
are lexicographically greater than `native()` for the elements of `p`;
|
| 856 |
+
otherwise,
|
| 857 |
+
- `0`.
|
| 858 |
+
|
| 859 |
+
*Remarks:* The elements are determined as if by iteration over the
|
| 860 |
+
half-open range \[`begin()`, `end()`) for `*this` and `p`.
|
| 861 |
+
|
| 862 |
+
``` cpp
|
| 863 |
+
int compare(const string_type& s) const
|
| 864 |
+
int compare(basic_string_view<value_type> s) const;
|
| 865 |
+
```
|
| 866 |
+
|
| 867 |
+
*Returns:* `compare(path(s))`.
|
| 868 |
+
|
| 869 |
+
``` cpp
|
| 870 |
+
int compare(const value_type* s) const
|
| 871 |
+
```
|
| 872 |
+
|
| 873 |
+
*Returns:* `compare(path(s))`.
|
| 874 |
+
|
| 875 |
+
##### `path` decomposition <a id="fs.path.decompose">[[fs.path.decompose]]</a>
|
| 876 |
+
|
| 877 |
+
``` cpp
|
| 878 |
+
path root_name() const;
|
| 879 |
+
```
|
| 880 |
+
|
| 881 |
+
*Returns:* *root-name*, if the pathname in the generic format includes
|
| 882 |
+
*root-name*, otherwise `path()`.
|
| 883 |
+
|
| 884 |
+
``` cpp
|
| 885 |
+
path root_directory() const;
|
| 886 |
+
```
|
| 887 |
+
|
| 888 |
+
*Returns:* *root-directory*, if the pathname in the generic format
|
| 889 |
+
includes *root-directory*, otherwise `path()`.
|
| 890 |
+
|
| 891 |
+
``` cpp
|
| 892 |
+
path root_path() const;
|
| 893 |
+
```
|
| 894 |
+
|
| 895 |
+
*Returns:* `root_name() / root_directory()`.
|
| 896 |
+
|
| 897 |
+
``` cpp
|
| 898 |
+
path relative_path() const;
|
| 899 |
+
```
|
| 900 |
+
|
| 901 |
+
*Returns:* A `path` composed from the pathname in the generic format, if
|
| 902 |
+
`!empty()`, beginning with the first *filename* after *root-path*.
|
| 903 |
+
Otherwise, `path()`.
|
| 904 |
+
|
| 905 |
+
``` cpp
|
| 906 |
+
path parent_path() const;
|
| 907 |
+
```
|
| 908 |
+
|
| 909 |
+
*Returns:* `*this` if `!has_relative_path()`, otherwise a path whose
|
| 910 |
+
generic format pathname is the longest prefix of the generic format
|
| 911 |
+
pathname of `*this` that produces one fewer element in its iteration.
|
| 912 |
+
|
| 913 |
+
``` cpp
|
| 914 |
+
path filename() const;
|
| 915 |
+
```
|
| 916 |
+
|
| 917 |
+
*Returns:* `relative_path().empty() ? path() : *–end()`.
|
| 918 |
+
|
| 919 |
+
[*Example 6*:
|
| 920 |
+
|
| 921 |
+
``` cpp
|
| 922 |
+
path("/foo/bar.txt").filename(); // yields "bar.txt"
|
| 923 |
+
path("/foo/bar").filename(); // yields "bar"
|
| 924 |
+
path("/foo/bar/").filename(); // yields ""
|
| 925 |
+
path("/").filename(); // yields ""
|
| 926 |
+
path("//host").filename(); // yields ""
|
| 927 |
+
path(".").filename(); // yields "."
|
| 928 |
+
path("..").filename(); // yields ".."
|
| 929 |
+
```
|
| 930 |
+
|
| 931 |
+
— *end example*]
|
| 932 |
+
|
| 933 |
+
``` cpp
|
| 934 |
+
path stem() const;
|
| 935 |
+
```
|
| 936 |
+
|
| 937 |
+
*Returns:* Let `f` be the generic format pathname of `filename()`.
|
| 938 |
+
Returns a path whose pathname in the generic format is
|
| 939 |
+
|
| 940 |
+
- `f`, if it contains no periods other than a leading period or consists
|
| 941 |
+
solely of one or two periods;
|
| 942 |
+
- otherwise, the prefix of `f` ending before its last period.
|
| 943 |
+
|
| 944 |
+
[*Example 7*:
|
| 945 |
+
|
| 946 |
+
``` cpp
|
| 947 |
+
std::cout << path("/foo/bar.txt").stem(); // outputs "bar"
|
| 948 |
+
path p = "foo.bar.baz.tar";
|
| 949 |
+
for (; !p.extension().empty(); p = p.stem())
|
| 950 |
+
std::cout << p.extension() << '\n';
|
| 951 |
+
// outputs: .tar
|
| 952 |
+
// .baz
|
| 953 |
+
// .bar
|
| 954 |
+
```
|
| 955 |
+
|
| 956 |
+
— *end example*]
|
| 957 |
+
|
| 958 |
+
``` cpp
|
| 959 |
+
path extension() const;
|
| 960 |
+
```
|
| 961 |
+
|
| 962 |
+
*Returns:* a path whose pathname in the generic format is the suffix of
|
| 963 |
+
`filename()` not included in `stem()`.
|
| 964 |
+
|
| 965 |
+
[*Example 8*:
|
| 966 |
+
|
| 967 |
+
``` cpp
|
| 968 |
+
path("/foo/bar.txt").extension(); // yields ".txt" and stem() is "bar"
|
| 969 |
+
path("/foo/bar").extension(); // yields "" and stem() is "bar"
|
| 970 |
+
path("/foo/.profile").extension(); // yields "" and stem() is ".profile"
|
| 971 |
+
path(".bar").extension(); // yields "" and stem() is ".bar"
|
| 972 |
+
path("..bar").extension(); // yields ".bar" and stem() is "."
|
| 973 |
+
```
|
| 974 |
+
|
| 975 |
+
— *end example*]
|
| 976 |
+
|
| 977 |
+
[*Note 4*: The period is included in the return value so that it is
|
| 978 |
+
possible to distinguish between no extension and an empty
|
| 979 |
+
extension. — *end note*]
|
| 980 |
+
|
| 981 |
+
[*Note 5*: On non-POSIX operating systems, for a path `p`, it may not
|
| 982 |
+
be the case that `p.stem() + p.extension() == p.filename()`, even though
|
| 983 |
+
the generic format pathnames are the same. — *end note*]
|
| 984 |
+
|
| 985 |
+
##### `path` query <a id="fs.path.query">[[fs.path.query]]</a>
|
| 986 |
+
|
| 987 |
+
``` cpp
|
| 988 |
+
bool empty() const noexcept;
|
| 989 |
+
```
|
| 990 |
+
|
| 991 |
+
*Returns:* `true` if the pathname in the generic format is empty, else
|
| 992 |
+
`false`.
|
| 993 |
+
|
| 994 |
+
``` cpp
|
| 995 |
+
bool has_root_path() const;
|
| 996 |
+
```
|
| 997 |
+
|
| 998 |
+
*Returns:* `!root_path().empty()`.
|
| 999 |
+
|
| 1000 |
+
``` cpp
|
| 1001 |
+
bool has_root_name() const;
|
| 1002 |
+
```
|
| 1003 |
+
|
| 1004 |
+
*Returns:* `!root_name().empty()`.
|
| 1005 |
+
|
| 1006 |
+
``` cpp
|
| 1007 |
+
bool has_root_directory() const;
|
| 1008 |
+
```
|
| 1009 |
+
|
| 1010 |
+
*Returns:* `!root_directory().empty()`.
|
| 1011 |
+
|
| 1012 |
+
``` cpp
|
| 1013 |
+
bool has_relative_path() const;
|
| 1014 |
+
```
|
| 1015 |
+
|
| 1016 |
+
*Returns:* `!relative_path().empty()`.
|
| 1017 |
+
|
| 1018 |
+
``` cpp
|
| 1019 |
+
bool has_parent_path() const;
|
| 1020 |
+
```
|
| 1021 |
+
|
| 1022 |
+
*Returns:* `!parent_path().empty()`.
|
| 1023 |
+
|
| 1024 |
+
``` cpp
|
| 1025 |
+
bool has_filename() const;
|
| 1026 |
+
```
|
| 1027 |
+
|
| 1028 |
+
*Returns:* `!filename().empty()`.
|
| 1029 |
+
|
| 1030 |
+
``` cpp
|
| 1031 |
+
bool has_stem() const;
|
| 1032 |
+
```
|
| 1033 |
+
|
| 1034 |
+
*Returns:* `!stem().empty()`.
|
| 1035 |
+
|
| 1036 |
+
``` cpp
|
| 1037 |
+
bool has_extension() const;
|
| 1038 |
+
```
|
| 1039 |
+
|
| 1040 |
+
*Returns:* `!extension().empty()`.
|
| 1041 |
+
|
| 1042 |
+
``` cpp
|
| 1043 |
+
bool is_absolute() const;
|
| 1044 |
+
```
|
| 1045 |
+
|
| 1046 |
+
*Returns:* `true` if the pathname in the native format contains an
|
| 1047 |
+
absolute path ([[fs.def.absolute.path]]), else `false`.
|
| 1048 |
+
|
| 1049 |
+
[*Example 9*: `path("/").is_absolute()` is `true` for POSIX-based
|
| 1050 |
+
operating systems, and `false` for Windows-based operating
|
| 1051 |
+
systems. — *end example*]
|
| 1052 |
+
|
| 1053 |
+
``` cpp
|
| 1054 |
+
bool is_relative() const;
|
| 1055 |
+
```
|
| 1056 |
+
|
| 1057 |
+
*Returns:* `!is_absolute()`.
|
| 1058 |
+
|
| 1059 |
+
##### `path` generation <a id="fs.path.gen">[[fs.path.gen]]</a>
|
| 1060 |
+
|
| 1061 |
+
``` cpp
|
| 1062 |
+
path lexically_normal() const;
|
| 1063 |
+
```
|
| 1064 |
+
|
| 1065 |
+
*Returns:* A path whose pathname in the generic format is the normal
|
| 1066 |
+
form ([[fs.def.normal.form]]) of the pathname in the generic format of
|
| 1067 |
+
`*this`.
|
| 1068 |
+
|
| 1069 |
+
[*Example 10*:
|
| 1070 |
+
|
| 1071 |
+
``` cpp
|
| 1072 |
+
assert(path("foo/./bar/..").lexically_normal() == "foo/");
|
| 1073 |
+
assert(path("foo/.///bar/../").lexically_normal() == "foo/");
|
| 1074 |
+
```
|
| 1075 |
+
|
| 1076 |
+
The above assertions will succeed. On Windows, the returned path’s
|
| 1077 |
+
*directory-separator* characters will be backslashes rather than
|
| 1078 |
+
slashes, but that does not affect `path` equality.
|
| 1079 |
+
|
| 1080 |
+
— *end example*]
|
| 1081 |
+
|
| 1082 |
+
``` cpp
|
| 1083 |
+
path lexically_relative(const path& base) const;
|
| 1084 |
+
```
|
| 1085 |
+
|
| 1086 |
+
*Returns:* `*this` made relative to `base`. Does not
|
| 1087 |
+
resolve ([[fs.def.pathres]]) symlinks. Does not first
|
| 1088 |
+
normalize ([[fs.def.normal.form]]) `*this` or `base`.
|
| 1089 |
+
|
| 1090 |
+
*Effects:* If `root_name() != base.root_name()` is `true` or
|
| 1091 |
+
`is_absolute() != base.is_absolute()` is `true` or
|
| 1092 |
+
`!has_root_directory() && base.has_root_directory()` is `true`, returns
|
| 1093 |
+
`path()`. Determines the first mismatched element of `*this` and `base`
|
| 1094 |
+
as if by:
|
| 1095 |
+
|
| 1096 |
+
``` cpp
|
| 1097 |
+
auto [a, b] = mismatch(begin(), end(), base.begin(), base.end());
|
| 1098 |
+
```
|
| 1099 |
+
|
| 1100 |
+
Then,
|
| 1101 |
+
|
| 1102 |
+
- if `a == end()` and `b == base.end()`, returns `path(".")`; otherwise
|
| 1103 |
+
- let `n` be the number of *filename* elements in \[`b`, `base.end()`)
|
| 1104 |
+
that are not *dot* or *dot-dot* minus the number that are *dot-dot*.
|
| 1105 |
+
If `n<0,` returns `path()`; otherwise
|
| 1106 |
+
- returns an object of class `path` that is default-constructed,
|
| 1107 |
+
followed by
|
| 1108 |
+
- application of `operator/=(path(".."))` `n` times, and then
|
| 1109 |
+
- application of `operator/=` for each element in \[`a`, `end()`).
|
| 1110 |
+
|
| 1111 |
+
[*Example 11*:
|
| 1112 |
+
|
| 1113 |
+
``` cpp
|
| 1114 |
+
assert(path("/a/d").lexically_relative("/a/b/c") == "../../d");
|
| 1115 |
+
assert(path("/a/b/c").lexically_relative("/a/d") == "../b/c");
|
| 1116 |
+
assert(path("a/b/c").lexically_relative("a") == "b/c");
|
| 1117 |
+
assert(path("a/b/c").lexically_relative("a/b/c/x/y") == "../..");
|
| 1118 |
+
assert(path("a/b/c").lexically_relative("a/b/c") == ".");
|
| 1119 |
+
assert(path("a/b").lexically_relative("c/d") == "../../a/b");
|
| 1120 |
+
```
|
| 1121 |
+
|
| 1122 |
+
The above assertions will succeed. On Windows, the returned path’s
|
| 1123 |
+
*directory-separator* characters will be backslashes rather than
|
| 1124 |
+
slashes, but that does not affect `path` equality.
|
| 1125 |
+
|
| 1126 |
+
— *end example*]
|
| 1127 |
+
|
| 1128 |
+
[*Note 6*: If symlink following semantics are desired, use the
|
| 1129 |
+
operational function `relative()`. — *end note*]
|
| 1130 |
+
|
| 1131 |
+
[*Note 7*: If normalization ([[fs.def.normal.form]]) is needed to
|
| 1132 |
+
ensure consistent matching of elements, apply `lexically_normal()` to
|
| 1133 |
+
`*this`, `base`, or both. — *end note*]
|
| 1134 |
+
|
| 1135 |
+
``` cpp
|
| 1136 |
+
path lexically_proximate(const path& base) const;
|
| 1137 |
+
```
|
| 1138 |
+
|
| 1139 |
+
*Returns:* If the value of `lexically_relative(base)` is not an empty
|
| 1140 |
+
path, return it. Otherwise return `*this`.
|
| 1141 |
+
|
| 1142 |
+
[*Note 8*: If symlink following semantics are desired, use the
|
| 1143 |
+
operational function `proximate()`. — *end note*]
|
| 1144 |
+
|
| 1145 |
+
[*Note 9*: If normalization ([[fs.def.normal.form]]) is needed to
|
| 1146 |
+
ensure consistent matching of elements, apply `lexically_normal()` to
|
| 1147 |
+
`*this`, `base`, or both. — *end note*]
|
| 1148 |
+
|
| 1149 |
+
#### `path` iterators <a id="fs.path.itr">[[fs.path.itr]]</a>
|
| 1150 |
+
|
| 1151 |
+
Path iterators iterate over the elements of the pathname in the generic
|
| 1152 |
+
format ([[fs.path.generic]]).
|
| 1153 |
+
|
| 1154 |
+
A `path::iterator` is a constant iterator satisfying all the
|
| 1155 |
+
requirements of a bidirectional iterator ([[bidirectional.iterators]])
|
| 1156 |
+
except that, for dereferenceable iterators `a` and `b` of type
|
| 1157 |
+
`path::iterator` with `a == b`, there is no requirement that `*a` and
|
| 1158 |
+
`*b` are bound to the same object. Its `value_type` is `path`.
|
| 1159 |
+
|
| 1160 |
+
Calling any non-const member function of a `path` object invalidates all
|
| 1161 |
+
iterators referring to elements of that object.
|
| 1162 |
+
|
| 1163 |
+
For the elements of the pathname in the generic format, the forward
|
| 1164 |
+
traversal order is as follows:
|
| 1165 |
+
|
| 1166 |
+
- The *root-name* element, if present.
|
| 1167 |
+
- The *root-directory* element, if present. \[*Note 1*: The generic
|
| 1168 |
+
format is required to ensure lexicographical comparison works
|
| 1169 |
+
correctly. — *end note*]
|
| 1170 |
+
- Each successive *filename* element, if present.
|
| 1171 |
+
- An empty element, if a trailing non-root *directory-separator* is
|
| 1172 |
+
present.
|
| 1173 |
+
|
| 1174 |
+
The backward traversal order is the reverse of forward traversal.
|
| 1175 |
+
|
| 1176 |
+
``` cpp
|
| 1177 |
+
iterator begin() const;
|
| 1178 |
+
```
|
| 1179 |
+
|
| 1180 |
+
*Returns:* An iterator for the first present element in the traversal
|
| 1181 |
+
list above. If no elements are present, the end iterator.
|
| 1182 |
+
|
| 1183 |
+
``` cpp
|
| 1184 |
+
iterator end() const;
|
| 1185 |
+
```
|
| 1186 |
+
|
| 1187 |
+
*Returns:* The end iterator.
|
| 1188 |
+
|
| 1189 |
+
#### `path` non-member functions <a id="fs.path.nonmember">[[fs.path.nonmember]]</a>
|
| 1190 |
+
|
| 1191 |
+
``` cpp
|
| 1192 |
+
void swap(path& lhs, path& rhs) noexcept;
|
| 1193 |
+
```
|
| 1194 |
+
|
| 1195 |
+
*Effects:* Equivalent to: `lhs.swap(rhs);`
|
| 1196 |
+
|
| 1197 |
+
``` cpp
|
| 1198 |
+
size_t hash_value (const path& p) noexcept;
|
| 1199 |
+
```
|
| 1200 |
+
|
| 1201 |
+
*Returns:* A hash value for the path `p`. If for two paths, `p1 == p2`
|
| 1202 |
+
then `hash_value(p1) == hash_value(p2)`.
|
| 1203 |
+
|
| 1204 |
+
``` cpp
|
| 1205 |
+
bool operator< (const path& lhs, const path& rhs) noexcept;
|
| 1206 |
+
```
|
| 1207 |
+
|
| 1208 |
+
*Returns:* `lhs.compare(rhs) < 0`.
|
| 1209 |
+
|
| 1210 |
+
``` cpp
|
| 1211 |
+
bool operator<=(const path& lhs, const path& rhs) noexcept;
|
| 1212 |
+
```
|
| 1213 |
+
|
| 1214 |
+
*Returns:* `!(rhs < lhs)`.
|
| 1215 |
+
|
| 1216 |
+
``` cpp
|
| 1217 |
+
bool operator> (const path& lhs, const path& rhs) noexcept;
|
| 1218 |
+
```
|
| 1219 |
+
|
| 1220 |
+
*Returns:* `rhs < lhs`.
|
| 1221 |
+
|
| 1222 |
+
``` cpp
|
| 1223 |
+
bool operator>=(const path& lhs, const path& rhs) noexcept;
|
| 1224 |
+
```
|
| 1225 |
+
|
| 1226 |
+
*Returns:* `!(lhs < rhs)`.
|
| 1227 |
+
|
| 1228 |
+
``` cpp
|
| 1229 |
+
bool operator==(const path& lhs, const path& rhs) noexcept;
|
| 1230 |
+
```
|
| 1231 |
+
|
| 1232 |
+
*Returns:* `!(lhs < rhs) && !(rhs < lhs)`.
|
| 1233 |
+
|
| 1234 |
+
[*Note 1*:
|
| 1235 |
+
|
| 1236 |
+
Path equality and path equivalence have different semantics.
|
| 1237 |
+
|
| 1238 |
+
- Equality is determined by the `path` non-member `operator==`, which
|
| 1239 |
+
considers the two path’s lexical representations only.
|
| 1240 |
+
\[*Example 1*: `path("foo") == "bar"` is never
|
| 1241 |
+
`true`. — *end example*]
|
| 1242 |
+
- Equivalence is determined by the `equivalent()` non-member function,
|
| 1243 |
+
which determines if two paths resolve ([[fs.def.pathres]]) to the
|
| 1244 |
+
same file system entity. \[*Example 2*: `equivalent("foo", "bar")`
|
| 1245 |
+
will be `true` when both paths resolve to the same
|
| 1246 |
+
file. — *end example*]
|
| 1247 |
+
|
| 1248 |
+
Programmers wishing to determine if two paths are “the same” must decide
|
| 1249 |
+
if “the same” means “the same representation” or “resolve to the same
|
| 1250 |
+
actual file”, and choose the appropriate function accordingly.
|
| 1251 |
+
|
| 1252 |
+
— *end note*]
|
| 1253 |
+
|
| 1254 |
+
``` cpp
|
| 1255 |
+
bool operator!=(const path& lhs, const path& rhs) noexcept;
|
| 1256 |
+
```
|
| 1257 |
+
|
| 1258 |
+
*Returns:* `!(lhs == rhs)`.
|
| 1259 |
+
|
| 1260 |
+
``` cpp
|
| 1261 |
+
path operator/ (const path& lhs, const path& rhs);
|
| 1262 |
+
```
|
| 1263 |
+
|
| 1264 |
+
*Effects:* Equivalent to: `return path(lhs) /= rhs;`
|
| 1265 |
+
|
| 1266 |
+
##### `path` inserter and extractor <a id="fs.path.io">[[fs.path.io]]</a>
|
| 1267 |
+
|
| 1268 |
+
``` cpp
|
| 1269 |
+
template <class charT, class traits>
|
| 1270 |
+
basic_ostream<charT, traits>&
|
| 1271 |
+
operator<<(basic_ostream<charT, traits>& os, const path& p);
|
| 1272 |
+
```
|
| 1273 |
+
|
| 1274 |
+
*Effects:* Equivalent to: `os << quoted(p.string<charT, traits>());`
|
| 1275 |
+
|
| 1276 |
+
[*Note 2*: The `quoted` function is described
|
| 1277 |
+
in [[quoted.manip]]. — *end note*]
|
| 1278 |
+
|
| 1279 |
+
*Returns:* `os`.
|
| 1280 |
+
|
| 1281 |
+
``` cpp
|
| 1282 |
+
template <class charT, class traits>
|
| 1283 |
+
basic_istream<charT, traits>&
|
| 1284 |
+
operator>>(basic_istream<charT, traits>& is, path& p);
|
| 1285 |
+
```
|
| 1286 |
+
|
| 1287 |
+
*Effects:* Equivalent to:
|
| 1288 |
+
|
| 1289 |
+
``` cpp
|
| 1290 |
+
basic_string<charT, traits> tmp;
|
| 1291 |
+
is >> quoted(tmp);
|
| 1292 |
+
p = tmp;
|
| 1293 |
+
```
|
| 1294 |
+
|
| 1295 |
+
*Returns:* `is`.
|
| 1296 |
+
|
| 1297 |
+
##### `path` factory functions <a id="fs.path.factory">[[fs.path.factory]]</a>
|
| 1298 |
+
|
| 1299 |
+
``` cpp
|
| 1300 |
+
template <class Source>
|
| 1301 |
+
path u8path(const Source& source);
|
| 1302 |
+
template <class InputIterator>
|
| 1303 |
+
path u8path(InputIterator first, InputIterator last);
|
| 1304 |
+
```
|
| 1305 |
+
|
| 1306 |
+
*Requires:* The `source` and \[`first`, `last`) sequences are UTF-8
|
| 1307 |
+
encoded. The value type of `Source` and `InputIterator` is `char`.
|
| 1308 |
+
|
| 1309 |
+
*Returns:*
|
| 1310 |
+
|
| 1311 |
+
- If `value_type` is `char` and the current native narrow
|
| 1312 |
+
encoding ([[fs.def.native.encode]]) is UTF-8, return `path(source)`
|
| 1313 |
+
or `path(first, last)`; otherwise,
|
| 1314 |
+
- if `value_type` is `wchar_t` and the native wide encoding is UTF-16,
|
| 1315 |
+
or if `value_type` is `char16_t` or `char32_t`, convert `source` or
|
| 1316 |
+
\[`first`, `last`) to a temporary, `tmp`, of type `string_type` and
|
| 1317 |
+
return `path(tmp)`; otherwise,
|
| 1318 |
+
- convert `source` or \[`first`, `last`) to a temporary, `tmp`, of type
|
| 1319 |
+
`u32string` and return `path(tmp)`.
|
| 1320 |
+
|
| 1321 |
+
*Remarks:* Argument format conversion ([[fs.path.fmt.cvt]]) applies to
|
| 1322 |
+
the arguments for these functions. How Unicode encoding conversions are
|
| 1323 |
+
performed is unspecified.
|
| 1324 |
+
|
| 1325 |
+
[*Example 1*:
|
| 1326 |
+
|
| 1327 |
+
A string is to be read from a database that is encoded in UTF-8, and
|
| 1328 |
+
used to create a directory using the native encoding for filenames:
|
| 1329 |
+
|
| 1330 |
+
``` cpp
|
| 1331 |
+
namespace fs = std::filesystem;
|
| 1332 |
+
std::string utf8_string = read_utf8_data();
|
| 1333 |
+
fs::create_directory(fs::u8path(utf8_string));
|
| 1334 |
+
```
|
| 1335 |
+
|
| 1336 |
+
For POSIX-based operating systems with the native narrow encoding set to
|
| 1337 |
+
UTF-8, no encoding or type conversion occurs.
|
| 1338 |
+
|
| 1339 |
+
For POSIX-based operating systems with the native narrow encoding not
|
| 1340 |
+
set to UTF-8, a conversion to UTF-32 occurs, followed by a conversion to
|
| 1341 |
+
the current native narrow encoding. Some Unicode characters may have no
|
| 1342 |
+
native character set representation.
|
| 1343 |
+
|
| 1344 |
+
For Windows-based operating systems a conversion from UTF-8 to UTF-16
|
| 1345 |
+
occurs.
|
| 1346 |
+
|
| 1347 |
+
— *end example*]
|
| 1348 |
+
|