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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### `path` members <a id="fs.path.member">[[fs.path.member]]</a>
|
| 2 |
+
|
| 3 |
+
##### `path` constructors <a id="fs.path.construct">[[fs.path.construct]]</a>
|
| 4 |
+
|
| 5 |
+
``` cpp
|
| 6 |
+
path() noexcept;
|
| 7 |
+
```
|
| 8 |
+
|
| 9 |
+
*Effects:* Constructs an object of class `path`.
|
| 10 |
+
|
| 11 |
+
*Postconditions:* `empty() == true`.
|
| 12 |
+
|
| 13 |
+
``` cpp
|
| 14 |
+
path(const path& p);
|
| 15 |
+
path(path&& p) noexcept;
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
*Effects:* Constructs an object of class `path` having the same pathname
|
| 19 |
+
in the native and generic formats, respectively, as the original value
|
| 20 |
+
of `p`. In the second form, `p` is left in a valid but unspecified
|
| 21 |
+
state.
|
| 22 |
+
|
| 23 |
+
``` cpp
|
| 24 |
+
path(string_type&& source, format fmt = auto_format);
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
*Effects:* Constructs an object of class `path` for which the pathname
|
| 28 |
+
in the detected-format of `source` has the original value of
|
| 29 |
+
`source` ([[fs.path.fmt.cvt]]), converting format if
|
| 30 |
+
required ([[fs.path.fmt.cvt]]). `source` is left in a valid but
|
| 31 |
+
unspecified state.
|
| 32 |
+
|
| 33 |
+
``` cpp
|
| 34 |
+
template <class Source>
|
| 35 |
+
path(const Source& source, format fmt = auto_format);
|
| 36 |
+
template <class InputIterator>
|
| 37 |
+
path(InputIterator first, InputIterator last, format fmt = auto_format);
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
*Effects:* Let `s` be the effective range of `source` ([[fs.path.req]])
|
| 41 |
+
or the range \[`first`, `last`), with the encoding converted if
|
| 42 |
+
required ([[fs.path.cvt]]). Finds the detected-format of
|
| 43 |
+
`s` ([[fs.path.fmt.cvt]]) and constructs an object of class `path` for
|
| 44 |
+
which the pathname in that format is `s`.
|
| 45 |
+
|
| 46 |
+
``` cpp
|
| 47 |
+
template <class Source>
|
| 48 |
+
path(const Source& source, const locale& loc, format fmt = auto_format);
|
| 49 |
+
template <class InputIterator>
|
| 50 |
+
path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format);
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
*Requires:* The value type of `Source` and `InputIterator` is `char`.
|
| 54 |
+
|
| 55 |
+
*Effects:* Let `s` be the effective range of `source` or the range
|
| 56 |
+
\[`first`, `last`), after converting the encoding as follows:
|
| 57 |
+
|
| 58 |
+
- If `value_type` is `wchar_t`, converts to the native wide
|
| 59 |
+
encoding ([[fs.def.native.encode]]) using the
|
| 60 |
+
`codecvt<wchar_t, char, mbstate_t>` facet of `loc`.
|
| 61 |
+
- Otherwise a conversion is performed using the
|
| 62 |
+
`codecvt<wchar_t, char, mbstate_t>` facet of `loc`, and then a second
|
| 63 |
+
conversion to the current narrow encoding.
|
| 64 |
+
|
| 65 |
+
Finds the detected-format of `s` ([[fs.path.fmt.cvt]]) and constructs
|
| 66 |
+
an object of class `path` for which the pathname in that format is `s`.
|
| 67 |
+
|
| 68 |
+
[*Example 1*:
|
| 69 |
+
|
| 70 |
+
A string is to be read from a database that is encoded in ISO/IEC
|
| 71 |
+
8859-1, and used to create a directory:
|
| 72 |
+
|
| 73 |
+
``` cpp
|
| 74 |
+
namespace fs = std::filesystem;
|
| 75 |
+
std::string latin1_string = read_latin1_data();
|
| 76 |
+
codecvt_8859_1<wchar_t> latin1_facet;
|
| 77 |
+
std::locale latin1_locale(std::locale(), latin1_facet);
|
| 78 |
+
fs::create_directory(fs::path(latin1_string, latin1_locale));
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
For POSIX-based operating systems, the path is constructed by first
|
| 82 |
+
using `latin1_facet` to convert ISO/IEC 8859-1 encoded `latin1_string`
|
| 83 |
+
to a wide character string in the native wide
|
| 84 |
+
encoding ([[fs.def.native.encode]]). The resulting wide string is then
|
| 85 |
+
converted to a narrow character pathname string in the current native
|
| 86 |
+
narrow encoding. If the native wide encoding is UTF-16 or UTF-32, and
|
| 87 |
+
the current native narrow encoding is UTF-8, all of the characters in
|
| 88 |
+
the ISO/IEC 8859-1 character set will be converted to their Unicode
|
| 89 |
+
representation, but for other native narrow encodings some characters
|
| 90 |
+
may have no representation.
|
| 91 |
+
|
| 92 |
+
For Windows-based operating systems, the path is constructed by using
|
| 93 |
+
`latin1_facet` to convert ISO/IEC 8859-1 encoded `latin1_string` to a
|
| 94 |
+
UTF-16 encoded wide character pathname string. All of the characters in
|
| 95 |
+
the ISO/IEC 8859-1 character set will be converted to their Unicode
|
| 96 |
+
representation.
|
| 97 |
+
|
| 98 |
+
— *end example*]
|
| 99 |
+
|
| 100 |
+
##### `path` assignments <a id="fs.path.assign">[[fs.path.assign]]</a>
|
| 101 |
+
|
| 102 |
+
``` cpp
|
| 103 |
+
path& operator=(const path& p);
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
*Effects:* If `*this` and `p` are the same object, has no effect.
|
| 107 |
+
Otherwise, sets both respective pathnames of `*this` to the respective
|
| 108 |
+
pathnames of `p`.
|
| 109 |
+
|
| 110 |
+
*Returns:* `*this`.
|
| 111 |
+
|
| 112 |
+
``` cpp
|
| 113 |
+
path& operator=(path&& p) noexcept;
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
*Effects:* If `*this` and `p` are the same object, has no effect.
|
| 117 |
+
Otherwise, sets both respective pathnames of `*this` to the respective
|
| 118 |
+
pathnames of `p`. `p` is left in a valid but unspecified state.
|
| 119 |
+
|
| 120 |
+
[*Note 1*: A valid implementation is `swap(p)`. — *end note*]
|
| 121 |
+
|
| 122 |
+
*Returns:* `*this`.
|
| 123 |
+
|
| 124 |
+
``` cpp
|
| 125 |
+
path& operator=(string_type&& source);
|
| 126 |
+
path& assign(string_type&& source);
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
*Effects:* Sets the pathname in the detected-format of `source` to the
|
| 130 |
+
original value of `source`. `source` is left in a valid but unspecified
|
| 131 |
+
state.
|
| 132 |
+
|
| 133 |
+
*Returns:* `*this`.
|
| 134 |
+
|
| 135 |
+
``` cpp
|
| 136 |
+
template <class Source>
|
| 137 |
+
path& operator=(const Source& source);
|
| 138 |
+
template <class Source>
|
| 139 |
+
path& assign(const Source& source);
|
| 140 |
+
template <class InputIterator>
|
| 141 |
+
path& assign(InputIterator first, InputIterator last);
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
*Effects:* Let `s` be the effective range of `source` ([[fs.path.req]])
|
| 145 |
+
or the range \[`first`, `last`), with the encoding converted if
|
| 146 |
+
required ([[fs.path.cvt]]). Finds the detected-format of
|
| 147 |
+
`s` ([[fs.path.fmt.cvt]]) and sets the pathname in that format to `s`.
|
| 148 |
+
|
| 149 |
+
*Returns:* `*this`.
|
| 150 |
+
|
| 151 |
+
##### `path` appends <a id="fs.path.append">[[fs.path.append]]</a>
|
| 152 |
+
|
| 153 |
+
The append operations use `operator/=` to denote their semantic effect
|
| 154 |
+
of appending *preferred-separator* when needed.
|
| 155 |
+
|
| 156 |
+
``` cpp
|
| 157 |
+
path& operator/=(const path& p);
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
*Effects:* If
|
| 161 |
+
`p.is_absolute() || (p.has_root_name() && p.root_name() != root_name())`,
|
| 162 |
+
then `operator=(p)`.
|
| 163 |
+
|
| 164 |
+
Otherwise, modifies `*this` as if by these steps:
|
| 165 |
+
|
| 166 |
+
- If `p.has_root_directory()`, then removes any root directory and
|
| 167 |
+
relative path from the generic format pathname. Otherwise, if
|
| 168 |
+
`!has_root_directory() && is_absolute()` is `true` or if
|
| 169 |
+
`has_filename()` is `true`, then appends `path::preferred_separator`
|
| 170 |
+
to the generic format pathname.
|
| 171 |
+
- Then appends the native format pathname of `p`, omitting any
|
| 172 |
+
*root-name* from its generic format pathname, to the native format
|
| 173 |
+
pathname.
|
| 174 |
+
|
| 175 |
+
[*Example 2*:
|
| 176 |
+
|
| 177 |
+
Even if `//host` is interpreted as a *root-name*, both of the paths
|
| 178 |
+
`path("//host")/"foo"` and `path("//host/")/"foo"` equal `"//host/foo"`.
|
| 179 |
+
|
| 180 |
+
Expression examples:
|
| 181 |
+
|
| 182 |
+
``` cpp
|
| 183 |
+
// On POSIX,
|
| 184 |
+
path("foo") / ""; // yields "foo/"
|
| 185 |
+
path("foo") / "/bar"; // yields "/bar"
|
| 186 |
+
// On Windows, backslashes replace slashes in the above yields
|
| 187 |
+
|
| 188 |
+
// On Windows,
|
| 189 |
+
path("foo") / "c:/bar"; // yields "c:/bar"
|
| 190 |
+
path("foo") / "c:"; // yields "c:"
|
| 191 |
+
path("c:") / ""; // yields "c:"
|
| 192 |
+
path("c:foo") / "/bar"; // yields "c:/bar"
|
| 193 |
+
path("c:foo") / "c:bar"; // yields "c:foo/bar"
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
+
— *end example*]
|
| 197 |
+
|
| 198 |
+
*Returns:* `*this`.
|
| 199 |
+
|
| 200 |
+
``` cpp
|
| 201 |
+
template <class Source>
|
| 202 |
+
path& operator/=(const Source& source);
|
| 203 |
+
template <class Source>
|
| 204 |
+
path& append(const Source& source);
|
| 205 |
+
```
|
| 206 |
+
|
| 207 |
+
*Effects:* Equivalent to: `return operator/=(path(source));`
|
| 208 |
+
|
| 209 |
+
``` cpp
|
| 210 |
+
template <class InputIterator>
|
| 211 |
+
path& append(InputIterator first, InputIterator last);
|
| 212 |
+
```
|
| 213 |
+
|
| 214 |
+
*Effects:* Equivalent to: `return operator/=(path(first, last));`
|
| 215 |
+
|
| 216 |
+
##### `path` concatenation <a id="fs.path.concat">[[fs.path.concat]]</a>
|
| 217 |
+
|
| 218 |
+
``` cpp
|
| 219 |
+
path& operator+=(const path& x);
|
| 220 |
+
path& operator+=(const string_type& x);
|
| 221 |
+
path& operator+=(basic_string_view<value_type> x);
|
| 222 |
+
path& operator+=(const value_type* x);
|
| 223 |
+
path& operator+=(value_type x);
|
| 224 |
+
template <class Source>
|
| 225 |
+
path& operator+=(const Source& x);
|
| 226 |
+
template <class EcharT>
|
| 227 |
+
path& operator+=(EcharT x);
|
| 228 |
+
template <class Source>
|
| 229 |
+
path& concat(const Source& x);
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
*Effects:* Appends `path(x).native()` to the pathname in the native
|
| 233 |
+
format.
|
| 234 |
+
|
| 235 |
+
[*Note 2*: This directly manipulates the value of `native()` and may
|
| 236 |
+
not be portable between operating systems. — *end note*]
|
| 237 |
+
|
| 238 |
+
*Returns:* `*this`.
|
| 239 |
+
|
| 240 |
+
``` cpp
|
| 241 |
+
template <class InputIterator>
|
| 242 |
+
path& concat(InputIterator first, InputIterator last);
|
| 243 |
+
```
|
| 244 |
+
|
| 245 |
+
*Effects:* Equivalent to `return *this += path(first, last)`.
|
| 246 |
+
|
| 247 |
+
##### `path` modifiers <a id="fs.path.modifiers">[[fs.path.modifiers]]</a>
|
| 248 |
+
|
| 249 |
+
``` cpp
|
| 250 |
+
void clear() noexcept;
|
| 251 |
+
```
|
| 252 |
+
|
| 253 |
+
*Postconditions:* `empty() == true`.
|
| 254 |
+
|
| 255 |
+
``` cpp
|
| 256 |
+
path& make_preferred();
|
| 257 |
+
```
|
| 258 |
+
|
| 259 |
+
*Effects:* Each *directory-separator* of the pathname in the generic
|
| 260 |
+
format is converted to *preferred-separator*.
|
| 261 |
+
|
| 262 |
+
*Returns:* `*this`.
|
| 263 |
+
|
| 264 |
+
[*Example 3*:
|
| 265 |
+
|
| 266 |
+
``` cpp
|
| 267 |
+
path p("foo/bar");
|
| 268 |
+
std::cout << p << '\n';
|
| 269 |
+
p.make_preferred();
|
| 270 |
+
std::cout << p << '\n';
|
| 271 |
+
```
|
| 272 |
+
|
| 273 |
+
On an operating system where *preferred-separator* is a slash, the
|
| 274 |
+
output is:
|
| 275 |
+
|
| 276 |
+
``` cpp
|
| 277 |
+
"foo/bar"
|
| 278 |
+
"foo/bar"
|
| 279 |
+
```
|
| 280 |
+
|
| 281 |
+
On an operating system where *preferred-separator* is a backslash, the
|
| 282 |
+
output is:
|
| 283 |
+
|
| 284 |
+
``` cpp
|
| 285 |
+
"foo/bar"
|
| 286 |
+
"foo\bar"
|
| 287 |
+
```
|
| 288 |
+
|
| 289 |
+
— *end example*]
|
| 290 |
+
|
| 291 |
+
``` cpp
|
| 292 |
+
path& remove_filename();
|
| 293 |
+
```
|
| 294 |
+
|
| 295 |
+
*Postconditions:* `!has_filename()`.
|
| 296 |
+
|
| 297 |
+
*Effects:* Remove the generic format pathname of `filename()` from the
|
| 298 |
+
generic format pathname.
|
| 299 |
+
|
| 300 |
+
*Returns:* `*this`.
|
| 301 |
+
|
| 302 |
+
[*Example 4*:
|
| 303 |
+
|
| 304 |
+
``` cpp
|
| 305 |
+
path("foo/bar").remove_filename(); // yields "foo/"
|
| 306 |
+
path("foo/").remove_filename(); // yields "foo/"
|
| 307 |
+
path("/foo").remove_filename(); // yields "/"
|
| 308 |
+
path("/").remove_filename(); // yields "/"
|
| 309 |
+
```
|
| 310 |
+
|
| 311 |
+
— *end example*]
|
| 312 |
+
|
| 313 |
+
``` cpp
|
| 314 |
+
path& replace_filename(const path& replacement);
|
| 315 |
+
```
|
| 316 |
+
|
| 317 |
+
*Effects:* Equivalent to:
|
| 318 |
+
|
| 319 |
+
``` cpp
|
| 320 |
+
remove_filename();
|
| 321 |
+
operator/=(replacement);
|
| 322 |
+
```
|
| 323 |
+
|
| 324 |
+
*Returns:* `*this`.
|
| 325 |
+
|
| 326 |
+
[*Example 5*:
|
| 327 |
+
|
| 328 |
+
``` cpp
|
| 329 |
+
path("/foo").replace_filename("bar"); // yields "/bar" on POSIX
|
| 330 |
+
path("/").replace_filename("bar"); // yields "/bar" on POSIX
|
| 331 |
+
```
|
| 332 |
+
|
| 333 |
+
— *end example*]
|
| 334 |
+
|
| 335 |
+
``` cpp
|
| 336 |
+
path& replace_extension(const path& replacement = path());
|
| 337 |
+
```
|
| 338 |
+
|
| 339 |
+
*Effects:*
|
| 340 |
+
|
| 341 |
+
- Any existing `extension()(` [[fs.path.decompose]]`)` is removed from
|
| 342 |
+
the pathname in the generic format, then
|
| 343 |
+
- If `replacement` is not empty and does not begin with a dot character,
|
| 344 |
+
a dot character is appended to the pathname in the generic format,
|
| 345 |
+
then
|
| 346 |
+
- `operator+=(replacement);`.
|
| 347 |
+
|
| 348 |
+
*Returns:* `*this`.
|
| 349 |
+
|
| 350 |
+
``` cpp
|
| 351 |
+
void swap(path& rhs) noexcept;
|
| 352 |
+
```
|
| 353 |
+
|
| 354 |
+
*Effects:* Swaps the contents (in all formats) of the two paths.
|
| 355 |
+
|
| 356 |
+
*Complexity:* Constant time.
|
| 357 |
+
|
| 358 |
+
##### `path` native format observers <a id="fs.path.native.obs">[[fs.path.native.obs]]</a>
|
| 359 |
+
|
| 360 |
+
The string returned by all native format observers is in the native
|
| 361 |
+
pathname format ([[fs.def.native]]).
|
| 362 |
+
|
| 363 |
+
``` cpp
|
| 364 |
+
const string_type& native() const noexcept;
|
| 365 |
+
```
|
| 366 |
+
|
| 367 |
+
*Returns:* The pathname in the native format.
|
| 368 |
+
|
| 369 |
+
``` cpp
|
| 370 |
+
const value_type* c_str() const noexcept;
|
| 371 |
+
```
|
| 372 |
+
|
| 373 |
+
*Returns:* Equivalent to `native().c_str()`.
|
| 374 |
+
|
| 375 |
+
``` cpp
|
| 376 |
+
operator string_type() const;
|
| 377 |
+
```
|
| 378 |
+
|
| 379 |
+
*Returns:* `native()`.
|
| 380 |
+
|
| 381 |
+
[*Note 3*: Conversion to `string_type` is provided so that an object of
|
| 382 |
+
class `path` can be given as an argument to existing standard library
|
| 383 |
+
file stream constructors and open functions. — *end note*]
|
| 384 |
+
|
| 385 |
+
``` cpp
|
| 386 |
+
template <class EcharT, class traits = char_traits<EcharT>,
|
| 387 |
+
class Allocator = allocator<EcharT>>
|
| 388 |
+
basic_string<EcharT, traits, Allocator>
|
| 389 |
+
string(const Allocator& a = Allocator()) const;
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
*Returns:* `native()`.
|
| 393 |
+
|
| 394 |
+
*Remarks:* All memory allocation, including for the return value, shall
|
| 395 |
+
be performed by `a`. Conversion, if any, is specified by
|
| 396 |
+
[[fs.path.cvt]].
|
| 397 |
+
|
| 398 |
+
``` cpp
|
| 399 |
+
std::string string() const;
|
| 400 |
+
std::wstring wstring() const;
|
| 401 |
+
std::string u8string() const;
|
| 402 |
+
std::u16string u16string() const;
|
| 403 |
+
std::u32string u32string() const;
|
| 404 |
+
```
|
| 405 |
+
|
| 406 |
+
*Returns:* `pathstring`.
|
| 407 |
+
|
| 408 |
+
*Remarks:* Conversion, if any, is performed as specified by
|
| 409 |
+
[[fs.path.cvt]]. The encoding of the string returned by `u8string()` is
|
| 410 |
+
always UTF-8.
|
| 411 |
+
|
| 412 |
+
##### `path` generic format observers <a id="fs.path.generic.obs">[[fs.path.generic.obs]]</a>
|
| 413 |
+
|
| 414 |
+
Generic format observer functions return strings formatted according to
|
| 415 |
+
the generic pathname format ([[fs.path.generic]]). A single slash
|
| 416 |
+
(`'/'`) character is used as the *directory-separator*.
|
| 417 |
+
|
| 418 |
+
[*Example 1*:
|
| 419 |
+
|
| 420 |
+
On an operating system that uses backslash as its *preferred-separator*,
|
| 421 |
+
|
| 422 |
+
``` cpp
|
| 423 |
+
path("foo\\bar").generic_string()
|
| 424 |
+
```
|
| 425 |
+
|
| 426 |
+
returns `"foo/bar"`.
|
| 427 |
+
|
| 428 |
+
— *end example*]
|
| 429 |
+
|
| 430 |
+
``` cpp
|
| 431 |
+
template <class EcharT, class traits = char_traits<EcharT>,
|
| 432 |
+
class Allocator = allocator<EcharT>>
|
| 433 |
+
basic_string<EcharT, traits, Allocator>
|
| 434 |
+
generic_string(const Allocator& a = Allocator()) const;
|
| 435 |
+
```
|
| 436 |
+
|
| 437 |
+
*Returns:* The pathname in the generic format.
|
| 438 |
+
|
| 439 |
+
*Remarks:* All memory allocation, including for the return value, shall
|
| 440 |
+
be performed by `a`. Conversion, if any, is specified by
|
| 441 |
+
[[fs.path.cvt]].
|
| 442 |
+
|
| 443 |
+
``` cpp
|
| 444 |
+
std::string generic_string() const;
|
| 445 |
+
std::wstring generic_wstring() const;
|
| 446 |
+
std::string generic_u8string() const;
|
| 447 |
+
std::u16string generic_u16string() const;
|
| 448 |
+
std::u32string generic_u32string() const;
|
| 449 |
+
```
|
| 450 |
+
|
| 451 |
+
*Returns:* The pathname in the generic format.
|
| 452 |
+
|
| 453 |
+
*Remarks:* Conversion, if any, is specified by [[fs.path.cvt]]. The
|
| 454 |
+
encoding of the string returned by `generic_u8string()` is always UTF-8.
|
| 455 |
+
|
| 456 |
+
##### `path` compare <a id="fs.path.compare">[[fs.path.compare]]</a>
|
| 457 |
+
|
| 458 |
+
``` cpp
|
| 459 |
+
int compare(const path& p) const noexcept;
|
| 460 |
+
```
|
| 461 |
+
|
| 462 |
+
*Returns:*
|
| 463 |
+
|
| 464 |
+
- A value less than `0`, if `native()` for the elements of `*this` are
|
| 465 |
+
lexicographically less than `native()` for the elements of `p`;
|
| 466 |
+
otherwise,
|
| 467 |
+
- a value greater than `0`, if `native()` for the elements of `*this`
|
| 468 |
+
are lexicographically greater than `native()` for the elements of `p`;
|
| 469 |
+
otherwise,
|
| 470 |
+
- `0`.
|
| 471 |
+
|
| 472 |
+
*Remarks:* The elements are determined as if by iteration over the
|
| 473 |
+
half-open range \[`begin()`, `end()`) for `*this` and `p`.
|
| 474 |
+
|
| 475 |
+
``` cpp
|
| 476 |
+
int compare(const string_type& s) const
|
| 477 |
+
int compare(basic_string_view<value_type> s) const;
|
| 478 |
+
```
|
| 479 |
+
|
| 480 |
+
*Returns:* `compare(path(s))`.
|
| 481 |
+
|
| 482 |
+
``` cpp
|
| 483 |
+
int compare(const value_type* s) const
|
| 484 |
+
```
|
| 485 |
+
|
| 486 |
+
*Returns:* `compare(path(s))`.
|
| 487 |
+
|
| 488 |
+
##### `path` decomposition <a id="fs.path.decompose">[[fs.path.decompose]]</a>
|
| 489 |
+
|
| 490 |
+
``` cpp
|
| 491 |
+
path root_name() const;
|
| 492 |
+
```
|
| 493 |
+
|
| 494 |
+
*Returns:* *root-name*, if the pathname in the generic format includes
|
| 495 |
+
*root-name*, otherwise `path()`.
|
| 496 |
+
|
| 497 |
+
``` cpp
|
| 498 |
+
path root_directory() const;
|
| 499 |
+
```
|
| 500 |
+
|
| 501 |
+
*Returns:* *root-directory*, if the pathname in the generic format
|
| 502 |
+
includes *root-directory*, otherwise `path()`.
|
| 503 |
+
|
| 504 |
+
``` cpp
|
| 505 |
+
path root_path() const;
|
| 506 |
+
```
|
| 507 |
+
|
| 508 |
+
*Returns:* `root_name() / root_directory()`.
|
| 509 |
+
|
| 510 |
+
``` cpp
|
| 511 |
+
path relative_path() const;
|
| 512 |
+
```
|
| 513 |
+
|
| 514 |
+
*Returns:* A `path` composed from the pathname in the generic format, if
|
| 515 |
+
`!empty()`, beginning with the first *filename* after *root-path*.
|
| 516 |
+
Otherwise, `path()`.
|
| 517 |
+
|
| 518 |
+
``` cpp
|
| 519 |
+
path parent_path() const;
|
| 520 |
+
```
|
| 521 |
+
|
| 522 |
+
*Returns:* `*this` if `!has_relative_path()`, otherwise a path whose
|
| 523 |
+
generic format pathname is the longest prefix of the generic format
|
| 524 |
+
pathname of `*this` that produces one fewer element in its iteration.
|
| 525 |
+
|
| 526 |
+
``` cpp
|
| 527 |
+
path filename() const;
|
| 528 |
+
```
|
| 529 |
+
|
| 530 |
+
*Returns:* `relative_path().empty() ? path() : *–end()`.
|
| 531 |
+
|
| 532 |
+
[*Example 6*:
|
| 533 |
+
|
| 534 |
+
``` cpp
|
| 535 |
+
path("/foo/bar.txt").filename(); // yields "bar.txt"
|
| 536 |
+
path("/foo/bar").filename(); // yields "bar"
|
| 537 |
+
path("/foo/bar/").filename(); // yields ""
|
| 538 |
+
path("/").filename(); // yields ""
|
| 539 |
+
path("//host").filename(); // yields ""
|
| 540 |
+
path(".").filename(); // yields "."
|
| 541 |
+
path("..").filename(); // yields ".."
|
| 542 |
+
```
|
| 543 |
+
|
| 544 |
+
— *end example*]
|
| 545 |
+
|
| 546 |
+
``` cpp
|
| 547 |
+
path stem() const;
|
| 548 |
+
```
|
| 549 |
+
|
| 550 |
+
*Returns:* Let `f` be the generic format pathname of `filename()`.
|
| 551 |
+
Returns a path whose pathname in the generic format is
|
| 552 |
+
|
| 553 |
+
- `f`, if it contains no periods other than a leading period or consists
|
| 554 |
+
solely of one or two periods;
|
| 555 |
+
- otherwise, the prefix of `f` ending before its last period.
|
| 556 |
+
|
| 557 |
+
[*Example 7*:
|
| 558 |
+
|
| 559 |
+
``` cpp
|
| 560 |
+
std::cout << path("/foo/bar.txt").stem(); // outputs "bar"
|
| 561 |
+
path p = "foo.bar.baz.tar";
|
| 562 |
+
for (; !p.extension().empty(); p = p.stem())
|
| 563 |
+
std::cout << p.extension() << '\n';
|
| 564 |
+
// outputs: .tar
|
| 565 |
+
// .baz
|
| 566 |
+
// .bar
|
| 567 |
+
```
|
| 568 |
+
|
| 569 |
+
— *end example*]
|
| 570 |
+
|
| 571 |
+
``` cpp
|
| 572 |
+
path extension() const;
|
| 573 |
+
```
|
| 574 |
+
|
| 575 |
+
*Returns:* a path whose pathname in the generic format is the suffix of
|
| 576 |
+
`filename()` not included in `stem()`.
|
| 577 |
+
|
| 578 |
+
[*Example 8*:
|
| 579 |
+
|
| 580 |
+
``` cpp
|
| 581 |
+
path("/foo/bar.txt").extension(); // yields ".txt" and stem() is "bar"
|
| 582 |
+
path("/foo/bar").extension(); // yields "" and stem() is "bar"
|
| 583 |
+
path("/foo/.profile").extension(); // yields "" and stem() is ".profile"
|
| 584 |
+
path(".bar").extension(); // yields "" and stem() is ".bar"
|
| 585 |
+
path("..bar").extension(); // yields ".bar" and stem() is "."
|
| 586 |
+
```
|
| 587 |
+
|
| 588 |
+
— *end example*]
|
| 589 |
+
|
| 590 |
+
[*Note 4*: The period is included in the return value so that it is
|
| 591 |
+
possible to distinguish between no extension and an empty
|
| 592 |
+
extension. — *end note*]
|
| 593 |
+
|
| 594 |
+
[*Note 5*: On non-POSIX operating systems, for a path `p`, it may not
|
| 595 |
+
be the case that `p.stem() + p.extension() == p.filename()`, even though
|
| 596 |
+
the generic format pathnames are the same. — *end note*]
|
| 597 |
+
|
| 598 |
+
##### `path` query <a id="fs.path.query">[[fs.path.query]]</a>
|
| 599 |
+
|
| 600 |
+
``` cpp
|
| 601 |
+
bool empty() const noexcept;
|
| 602 |
+
```
|
| 603 |
+
|
| 604 |
+
*Returns:* `true` if the pathname in the generic format is empty, else
|
| 605 |
+
`false`.
|
| 606 |
+
|
| 607 |
+
``` cpp
|
| 608 |
+
bool has_root_path() const;
|
| 609 |
+
```
|
| 610 |
+
|
| 611 |
+
*Returns:* `!root_path().empty()`.
|
| 612 |
+
|
| 613 |
+
``` cpp
|
| 614 |
+
bool has_root_name() const;
|
| 615 |
+
```
|
| 616 |
+
|
| 617 |
+
*Returns:* `!root_name().empty()`.
|
| 618 |
+
|
| 619 |
+
``` cpp
|
| 620 |
+
bool has_root_directory() const;
|
| 621 |
+
```
|
| 622 |
+
|
| 623 |
+
*Returns:* `!root_directory().empty()`.
|
| 624 |
+
|
| 625 |
+
``` cpp
|
| 626 |
+
bool has_relative_path() const;
|
| 627 |
+
```
|
| 628 |
+
|
| 629 |
+
*Returns:* `!relative_path().empty()`.
|
| 630 |
+
|
| 631 |
+
``` cpp
|
| 632 |
+
bool has_parent_path() const;
|
| 633 |
+
```
|
| 634 |
+
|
| 635 |
+
*Returns:* `!parent_path().empty()`.
|
| 636 |
+
|
| 637 |
+
``` cpp
|
| 638 |
+
bool has_filename() const;
|
| 639 |
+
```
|
| 640 |
+
|
| 641 |
+
*Returns:* `!filename().empty()`.
|
| 642 |
+
|
| 643 |
+
``` cpp
|
| 644 |
+
bool has_stem() const;
|
| 645 |
+
```
|
| 646 |
+
|
| 647 |
+
*Returns:* `!stem().empty()`.
|
| 648 |
+
|
| 649 |
+
``` cpp
|
| 650 |
+
bool has_extension() const;
|
| 651 |
+
```
|
| 652 |
+
|
| 653 |
+
*Returns:* `!extension().empty()`.
|
| 654 |
+
|
| 655 |
+
``` cpp
|
| 656 |
+
bool is_absolute() const;
|
| 657 |
+
```
|
| 658 |
+
|
| 659 |
+
*Returns:* `true` if the pathname in the native format contains an
|
| 660 |
+
absolute path ([[fs.def.absolute.path]]), else `false`.
|
| 661 |
+
|
| 662 |
+
[*Example 9*: `path("/").is_absolute()` is `true` for POSIX-based
|
| 663 |
+
operating systems, and `false` for Windows-based operating
|
| 664 |
+
systems. — *end example*]
|
| 665 |
+
|
| 666 |
+
``` cpp
|
| 667 |
+
bool is_relative() const;
|
| 668 |
+
```
|
| 669 |
+
|
| 670 |
+
*Returns:* `!is_absolute()`.
|
| 671 |
+
|
| 672 |
+
##### `path` generation <a id="fs.path.gen">[[fs.path.gen]]</a>
|
| 673 |
+
|
| 674 |
+
``` cpp
|
| 675 |
+
path lexically_normal() const;
|
| 676 |
+
```
|
| 677 |
+
|
| 678 |
+
*Returns:* A path whose pathname in the generic format is the normal
|
| 679 |
+
form ([[fs.def.normal.form]]) of the pathname in the generic format of
|
| 680 |
+
`*this`.
|
| 681 |
+
|
| 682 |
+
[*Example 10*:
|
| 683 |
+
|
| 684 |
+
``` cpp
|
| 685 |
+
assert(path("foo/./bar/..").lexically_normal() == "foo/");
|
| 686 |
+
assert(path("foo/.///bar/../").lexically_normal() == "foo/");
|
| 687 |
+
```
|
| 688 |
+
|
| 689 |
+
The above assertions will succeed. On Windows, the returned path’s
|
| 690 |
+
*directory-separator* characters will be backslashes rather than
|
| 691 |
+
slashes, but that does not affect `path` equality.
|
| 692 |
+
|
| 693 |
+
— *end example*]
|
| 694 |
+
|
| 695 |
+
``` cpp
|
| 696 |
+
path lexically_relative(const path& base) const;
|
| 697 |
+
```
|
| 698 |
+
|
| 699 |
+
*Returns:* `*this` made relative to `base`. Does not
|
| 700 |
+
resolve ([[fs.def.pathres]]) symlinks. Does not first
|
| 701 |
+
normalize ([[fs.def.normal.form]]) `*this` or `base`.
|
| 702 |
+
|
| 703 |
+
*Effects:* If `root_name() != base.root_name()` is `true` or
|
| 704 |
+
`is_absolute() != base.is_absolute()` is `true` or
|
| 705 |
+
`!has_root_directory() && base.has_root_directory()` is `true`, returns
|
| 706 |
+
`path()`. Determines the first mismatched element of `*this` and `base`
|
| 707 |
+
as if by:
|
| 708 |
+
|
| 709 |
+
``` cpp
|
| 710 |
+
auto [a, b] = mismatch(begin(), end(), base.begin(), base.end());
|
| 711 |
+
```
|
| 712 |
+
|
| 713 |
+
Then,
|
| 714 |
+
|
| 715 |
+
- if `a == end()` and `b == base.end()`, returns `path(".")`; otherwise
|
| 716 |
+
- let `n` be the number of *filename* elements in \[`b`, `base.end()`)
|
| 717 |
+
that are not *dot* or *dot-dot* minus the number that are *dot-dot*.
|
| 718 |
+
If `n<0,` returns `path()`; otherwise
|
| 719 |
+
- returns an object of class `path` that is default-constructed,
|
| 720 |
+
followed by
|
| 721 |
+
- application of `operator/=(path(".."))` `n` times, and then
|
| 722 |
+
- application of `operator/=` for each element in \[`a`, `end()`).
|
| 723 |
+
|
| 724 |
+
[*Example 11*:
|
| 725 |
+
|
| 726 |
+
``` cpp
|
| 727 |
+
assert(path("/a/d").lexically_relative("/a/b/c") == "../../d");
|
| 728 |
+
assert(path("/a/b/c").lexically_relative("/a/d") == "../b/c");
|
| 729 |
+
assert(path("a/b/c").lexically_relative("a") == "b/c");
|
| 730 |
+
assert(path("a/b/c").lexically_relative("a/b/c/x/y") == "../..");
|
| 731 |
+
assert(path("a/b/c").lexically_relative("a/b/c") == ".");
|
| 732 |
+
assert(path("a/b").lexically_relative("c/d") == "../../a/b");
|
| 733 |
+
```
|
| 734 |
+
|
| 735 |
+
The above assertions will succeed. On Windows, the returned path’s
|
| 736 |
+
*directory-separator* characters will be backslashes rather than
|
| 737 |
+
slashes, but that does not affect `path` equality.
|
| 738 |
+
|
| 739 |
+
— *end example*]
|
| 740 |
+
|
| 741 |
+
[*Note 6*: If symlink following semantics are desired, use the
|
| 742 |
+
operational function `relative()`. — *end note*]
|
| 743 |
+
|
| 744 |
+
[*Note 7*: If normalization ([[fs.def.normal.form]]) is needed to
|
| 745 |
+
ensure consistent matching of elements, apply `lexically_normal()` to
|
| 746 |
+
`*this`, `base`, or both. — *end note*]
|
| 747 |
+
|
| 748 |
+
``` cpp
|
| 749 |
+
path lexically_proximate(const path& base) const;
|
| 750 |
+
```
|
| 751 |
+
|
| 752 |
+
*Returns:* If the value of `lexically_relative(base)` is not an empty
|
| 753 |
+
path, return it. Otherwise return `*this`.
|
| 754 |
+
|
| 755 |
+
[*Note 8*: If symlink following semantics are desired, use the
|
| 756 |
+
operational function `proximate()`. — *end note*]
|
| 757 |
+
|
| 758 |
+
[*Note 9*: If normalization ([[fs.def.normal.form]]) is needed to
|
| 759 |
+
ensure consistent matching of elements, apply `lexically_normal()` to
|
| 760 |
+
`*this`, `base`, or both. — *end note*]
|
| 761 |
+
|