tmp/tmpfic2fm0l/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
### Class `path` <a id="fs.class.path">[[fs.class.path]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
An object of class `path` represents a path and contains a pathname.
|
| 4 |
Such an object is concerned only with the lexical and syntactic aspects
|
| 5 |
of a path. The path does not necessarily exist in external storage, and
|
| 6 |
the pathname is not necessarily valid for the current operating system
|
| 7 |
or for a particular file system.
|
|
@@ -23,22 +25,22 @@ elements of a path that determine if it is absolute are operating system
|
|
| 23 |
dependent. A *relative path* is a path that is not absolute, and as
|
| 24 |
such, only unambiguously identifies the location of a file when resolved
|
| 25 |
relative to an implied starting location. The elements of a path that
|
| 26 |
determine if it is relative are operating system dependent.
|
| 27 |
|
| 28 |
-
[*Note 2*: Pathnames “.”
|
| 29 |
|
| 30 |
A *pathname* is a character string that represents the name of a path.
|
| 31 |
Pathnames are formatted according to the generic pathname format grammar
|
| 32 |
[[fs.path.generic]] or according to an operating system dependent
|
| 33 |
*native pathname format* accepted by the host operating system.
|
| 34 |
|
| 35 |
*Pathname resolution* is the operating system dependent mechanism for
|
| 36 |
resolving a pathname to a particular file in a file hierarchy. There may
|
| 37 |
be multiple pathnames that resolve to the same file.
|
| 38 |
|
| 39 |
-
[*Example 1*: POSIX specifies the mechanism in section 4.
|
| 40 |
resolution. — *end example*]
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
namespace std::filesystem {
|
| 44 |
class path {
|
|
@@ -256,13 +258,13 @@ consisting solely of one and two period characters respectively, have
|
|
| 256 |
special meaning. The following characteristics of filenames are
|
| 257 |
operating system dependent:
|
| 258 |
|
| 259 |
- The permitted characters. \[*Example 1*: Some operating systems
|
| 260 |
prohibit the ASCII control characters (0x00 – 0x1F) in
|
| 261 |
-
filenames. — *end example*] \[*Note 1*:
|
| 262 |
-
|
| 263 |
-
Character Set:
|
| 264 |
`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`
|
| 265 |
`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`
|
| 266 |
`0 1 2 3 4 5 6 7 8 9 . _ -` — *end note*]
|
| 267 |
- The maximum permitted length.
|
| 268 |
- Filenames that are not permitted.
|
|
@@ -287,11 +289,11 @@ A *root-name* identifies the starting location for pathname resolution
|
|
| 287 |
required.
|
| 288 |
|
| 289 |
[*Note 2*: Many operating systems define a name beginning with two
|
| 290 |
*directory-separator* characters as a *root-name* that identifies
|
| 291 |
network or other resource locations. Some operating systems define a
|
| 292 |
-
single letter followed by a colon as a drive specifier
|
| 293 |
identifying a specific device such as a disk drive. — *end note*]
|
| 294 |
|
| 295 |
If a *root-name* is otherwise ambiguous, the possibility with the
|
| 296 |
longest sequence of characters is chosen.
|
| 297 |
|
|
@@ -303,11 +305,11 @@ longest sequence of characters is chosen.
|
|
| 303 |
|
| 304 |
1. If the path is empty, stop.
|
| 305 |
2. Replace each slash character in the *root-name* with a
|
| 306 |
*preferred-separator*.
|
| 307 |
3. Replace each *directory-separator* with a *preferred-separator*.
|
| 308 |
-
\[*Note 4*: The generic pathname grammar
|
| 309 |
*directory-separator* as one or more slashes and
|
| 310 |
*preferred-separator*s. — *end note*]
|
| 311 |
4. Remove each dot filename and any immediately following
|
| 312 |
*directory-separator*.
|
| 313 |
5. As long as any appear, remove a non-dot-dot filename immediately
|
|
@@ -347,11 +349,11 @@ path using either a pathname in the generic format [[fs.path.generic]]
|
|
| 347 |
or a pathname in the native format [[fs.class.path]]. Such an argument
|
| 348 |
is taken to be in the generic format if and only if it matches the
|
| 349 |
generic format and is not acceptable to the operating system as a native
|
| 350 |
path.
|
| 351 |
|
| 352 |
-
[*Note 2*: Some operating systems
|
| 353 |
distinguish between native format and generic format arguments. This is
|
| 354 |
by design as it simplifies use for operating systems that do not require
|
| 355 |
disambiguation. An implementation for an operating system where
|
| 356 |
disambiguation is required is permitted to distinguish between the
|
| 357 |
formats. — *end note*]
|
|
@@ -370,11 +372,11 @@ differently from paths for directories, the path shall be treated as a
|
|
| 370 |
directory path if its last element is a *directory-separator*, otherwise
|
| 371 |
it shall be treated as a path to a regular file.
|
| 372 |
|
| 373 |
[*Note 4*: A path stores a native format pathname
|
| 374 |
[[fs.path.native.obs]] and acts as if it also stores a generic format
|
| 375 |
-
pathname, related as given below. The implementation
|
| 376 |
generic format pathname based on the native format pathname (and
|
| 377 |
possibly other information) when requested. — *end note*]
|
| 378 |
|
| 379 |
When a path is constructed from or is assigned a single representation
|
| 380 |
separate from any path, the other representation is selected by the
|
|
@@ -392,11 +394,11 @@ the result of converting *p*. — *end note*]
|
|
| 392 |
|
| 393 |
The *native encoding* of an ordinary character string is the operating
|
| 394 |
system dependent current encoding for pathnames [[fs.class.path]]. The
|
| 395 |
*native encoding* for wide character strings is the
|
| 396 |
implementation-defined execution wide-character set encoding
|
| 397 |
-
[[
|
| 398 |
|
| 399 |
For member function arguments that take character sequences representing
|
| 400 |
paths and for member functions returning strings, value type and
|
| 401 |
encoding conversion is performed if the value type of the argument or
|
| 402 |
return value differs from `path::value_type`. For the argument or return
|
|
@@ -410,12 +412,12 @@ determined by its value type:
|
|
| 410 |
return values is performed. For Windows-based operating systems, the
|
| 411 |
native ordinary encoding is determined by calling a Windows API
|
| 412 |
function. — *end note*] \[*Note 7*: This results in behavior
|
| 413 |
identical to other C and C++ standard library functions that perform
|
| 414 |
file operations using ordinary character strings to identify paths.
|
| 415 |
-
Changing this behavior would be surprising and
|
| 416 |
-
prone. — *end note*]
|
| 417 |
- `wchar_t`: The encoding is the native wide encoding. The method of
|
| 418 |
conversion is unspecified. \[*Note 8*: For Windows-based operating
|
| 419 |
systems `path::value_type` is `wchar_t` so no conversion from
|
| 420 |
`wchar_t` value type arguments or to `wchar_t` value type return
|
| 421 |
values is performed. — *end note*]
|
|
@@ -459,11 +461,11 @@ participate in overload resolution unless `Source` denotes a type other
|
|
| 459 |
than `path`, and either
|
| 460 |
|
| 461 |
- `Source` is a specialization of `basic_string` or `basic_string_view`,
|
| 462 |
or
|
| 463 |
- the *qualified-id* `iterator_traits<decay_t<Source>>::value_type` is
|
| 464 |
-
valid and denotes a possibly
|
| 465 |
[[temp.deduct]].
|
| 466 |
|
| 467 |
[*Note 1*: See path conversions [[fs.path.cvt]] for how the value types
|
| 468 |
above and their encodings convert to `path::value_type` and its
|
| 469 |
encoding. — *end note*]
|
|
@@ -698,12 +700,12 @@ template<class Source>
|
|
| 698 |
```
|
| 699 |
|
| 700 |
*Effects:* Appends `path(x).native()` to the pathname in the native
|
| 701 |
format.
|
| 702 |
|
| 703 |
-
[*Note 2*: This directly manipulates the value of `native()`
|
| 704 |
-
not
|
| 705 |
|
| 706 |
*Returns:* `*this`.
|
| 707 |
|
| 708 |
``` cpp
|
| 709 |
path& operator+=(value_type x);
|
|
@@ -852,14 +854,10 @@ const value_type* c_str() const noexcept;
|
|
| 852 |
operator string_type() const;
|
| 853 |
```
|
| 854 |
|
| 855 |
*Returns:* `native()`.
|
| 856 |
|
| 857 |
-
[*Note 3*: Conversion to `string_type` is provided so that an object of
|
| 858 |
-
class `path` can be given as an argument to existing standard library
|
| 859 |
-
file stream constructors and open functions. — *end note*]
|
| 860 |
-
|
| 861 |
``` cpp
|
| 862 |
template<class EcharT, class traits = char_traits<EcharT>,
|
| 863 |
class Allocator = allocator<EcharT>>
|
| 864 |
basic_string<EcharT, traits, Allocator>
|
| 865 |
string(const Allocator& a = Allocator()) const;
|
|
@@ -1059,17 +1057,17 @@ path(".bar").extension(); // yields "" and stem() is ".bar"
|
|
| 1059 |
path("..bar").extension(); // yields ".bar" and stem() is "."
|
| 1060 |
```
|
| 1061 |
|
| 1062 |
— *end example*]
|
| 1063 |
|
| 1064 |
-
[*Note
|
| 1065 |
possible to distinguish between no extension and an empty
|
| 1066 |
extension. — *end note*]
|
| 1067 |
|
| 1068 |
-
[*Note
|
| 1069 |
-
|
| 1070 |
-
the generic format pathnames are the same. — *end note*]
|
| 1071 |
|
| 1072 |
##### Query <a id="fs.path.query">[[fs.path.query]]</a>
|
| 1073 |
|
| 1074 |
``` cpp
|
| 1075 |
[[nodiscard]] bool empty() const noexcept;
|
|
@@ -1168,25 +1166,21 @@ slashes, but that does not affect `path` equality.
|
|
| 1168 |
|
| 1169 |
``` cpp
|
| 1170 |
path lexically_relative(const path& base) const;
|
| 1171 |
```
|
| 1172 |
|
| 1173 |
-
*Returns:* `*this` made relative to `base`. Does not
|
| 1174 |
-
resolve [[fs.class.path]] symlinks. Does not first
|
| 1175 |
-
normalize [[fs.path.generic]] `*this` or `base`.
|
| 1176 |
-
|
| 1177 |
*Effects:* If:
|
| 1178 |
|
| 1179 |
- `root_name() != base.root_name()` is `true`, or
|
| 1180 |
- `is_absolute() != base.is_absolute()` is `true`, or
|
| 1181 |
- `!has_root_directory() && base.has_root_directory()` is `true`, or
|
| 1182 |
- any *filename* in `relative_path()` or `base.relative_path()` can be
|
| 1183 |
interpreted as a *root-name*,
|
| 1184 |
|
| 1185 |
returns `path()`.
|
| 1186 |
|
| 1187 |
-
[*Note
|
| 1188 |
*relative-path* is acceptable as a *root-name*. — *end note*]
|
| 1189 |
|
| 1190 |
Determines the first mismatched element of `*this` and `base` as if by:
|
| 1191 |
|
| 1192 |
``` cpp
|
|
@@ -1204,10 +1198,14 @@ Then,
|
|
| 1204 |
- returns an object of class `path` that is default-constructed,
|
| 1205 |
followed by
|
| 1206 |
- application of `operator/=(path(".."))` `n` times, and then
|
| 1207 |
- application of `operator/=` for each element in \[`a`, `end()`).
|
| 1208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1209 |
[*Example 11*:
|
| 1210 |
|
| 1211 |
``` cpp
|
| 1212 |
assert(path("/a/d").lexically_relative("/a/b/c") == "../../d");
|
| 1213 |
assert(path("/a/b/c").lexically_relative("/a/d") == "../b/c");
|
|
@@ -1221,28 +1219,28 @@ The above assertions will succeed. On Windows, the returned path’s
|
|
| 1221 |
*directory-separator* characters will be backslashes rather than
|
| 1222 |
slashes, but that does not affect `path` equality.
|
| 1223 |
|
| 1224 |
— *end example*]
|
| 1225 |
|
| 1226 |
-
[*Note
|
| 1227 |
operational function `relative()`. — *end note*]
|
| 1228 |
|
| 1229 |
-
[*Note
|
| 1230 |
consistent matching of elements, apply `lexically_normal()` to `*this`,
|
| 1231 |
`base`, or both. — *end note*]
|
| 1232 |
|
| 1233 |
``` cpp
|
| 1234 |
path lexically_proximate(const path& base) const;
|
| 1235 |
```
|
| 1236 |
|
| 1237 |
*Returns:* If the value of `lexically_relative(base)` is not an empty
|
| 1238 |
path, return it. Otherwise return `*this`.
|
| 1239 |
|
| 1240 |
-
[*Note
|
| 1241 |
operational function `proximate()`. — *end note*]
|
| 1242 |
|
| 1243 |
-
[*Note
|
| 1244 |
consistent matching of elements, apply `lexically_normal()` to `*this`,
|
| 1245 |
`base`, or both. — *end note*]
|
| 1246 |
|
| 1247 |
#### Iterators <a id="fs.path.itr">[[fs.path.itr]]</a>
|
| 1248 |
|
|
@@ -1347,14 +1345,10 @@ Path equality and path equivalence have different semantics.
|
|
| 1347 |
- Equivalence is determined by the `equivalent()` non-member function,
|
| 1348 |
which determines if two paths resolve [[fs.class.path]] to the same
|
| 1349 |
file system entity. \[*Example 2*: `equivalent("foo", "bar")` will be
|
| 1350 |
`true` when both paths resolve to the same file. — *end example*]
|
| 1351 |
|
| 1352 |
-
Programmers wishing to determine if two paths are “the same” must decide
|
| 1353 |
-
if “the same” means “the same representation” or “resolve to the same
|
| 1354 |
-
actual file”, and choose the appropriate function accordingly.
|
| 1355 |
-
|
| 1356 |
— *end note*]
|
| 1357 |
|
| 1358 |
``` cpp
|
| 1359 |
friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept;
|
| 1360 |
```
|
|
@@ -1365,5 +1359,15 @@ friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept;
|
|
| 1365 |
friend path operator/(const path& lhs, const path& rhs);
|
| 1366 |
```
|
| 1367 |
|
| 1368 |
*Effects:* Equivalent to: `return path(lhs) /= rhs;`
|
| 1369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
### Class `path` <a id="fs.class.path">[[fs.class.path]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="fs.class.path.general">[[fs.class.path.general]]</a>
|
| 4 |
+
|
| 5 |
An object of class `path` represents a path and contains a pathname.
|
| 6 |
Such an object is concerned only with the lexical and syntactic aspects
|
| 7 |
of a path. The path does not necessarily exist in external storage, and
|
| 8 |
the pathname is not necessarily valid for the current operating system
|
| 9 |
or for a particular file system.
|
|
|
|
| 25 |
dependent. A *relative path* is a path that is not absolute, and as
|
| 26 |
such, only unambiguously identifies the location of a file when resolved
|
| 27 |
relative to an implied starting location. The elements of a path that
|
| 28 |
determine if it is relative are operating system dependent.
|
| 29 |
|
| 30 |
+
[*Note 2*: Pathnames “.” and “..” are relative paths. — *end note*]
|
| 31 |
|
| 32 |
A *pathname* is a character string that represents the name of a path.
|
| 33 |
Pathnames are formatted according to the generic pathname format grammar
|
| 34 |
[[fs.path.generic]] or according to an operating system dependent
|
| 35 |
*native pathname format* accepted by the host operating system.
|
| 36 |
|
| 37 |
*Pathname resolution* is the operating system dependent mechanism for
|
| 38 |
resolving a pathname to a particular file in a file hierarchy. There may
|
| 39 |
be multiple pathnames that resolve to the same file.
|
| 40 |
|
| 41 |
+
[*Example 1*: POSIX specifies the mechanism in section 4.12, Pathname
|
| 42 |
resolution. — *end example*]
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
namespace std::filesystem {
|
| 46 |
class path {
|
|
|
|
| 258 |
special meaning. The following characteristics of filenames are
|
| 259 |
operating system dependent:
|
| 260 |
|
| 261 |
- The permitted characters. \[*Example 1*: Some operating systems
|
| 262 |
prohibit the ASCII control characters (0x00 – 0x1F) in
|
| 263 |
+
filenames. — *end example*] \[*Note 1*: Wider portability can be
|
| 264 |
+
achieved by limiting *filename* characters to the POSIX Portable
|
| 265 |
+
Filename Character Set:
|
| 266 |
`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`
|
| 267 |
`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`
|
| 268 |
`0 1 2 3 4 5 6 7 8 9 . _ -` — *end note*]
|
| 269 |
- The maximum permitted length.
|
| 270 |
- Filenames that are not permitted.
|
|
|
|
| 289 |
required.
|
| 290 |
|
| 291 |
[*Note 2*: Many operating systems define a name beginning with two
|
| 292 |
*directory-separator* characters as a *root-name* that identifies
|
| 293 |
network or other resource locations. Some operating systems define a
|
| 294 |
+
single letter followed by a colon as a drive specifier — a *root-name*
|
| 295 |
identifying a specific device such as a disk drive. — *end note*]
|
| 296 |
|
| 297 |
If a *root-name* is otherwise ambiguous, the possibility with the
|
| 298 |
longest sequence of characters is chosen.
|
| 299 |
|
|
|
|
| 305 |
|
| 306 |
1. If the path is empty, stop.
|
| 307 |
2. Replace each slash character in the *root-name* with a
|
| 308 |
*preferred-separator*.
|
| 309 |
3. Replace each *directory-separator* with a *preferred-separator*.
|
| 310 |
+
\[*Note 4*: The generic pathname grammar defines
|
| 311 |
*directory-separator* as one or more slashes and
|
| 312 |
*preferred-separator*s. — *end note*]
|
| 313 |
4. Remove each dot filename and any immediately following
|
| 314 |
*directory-separator*.
|
| 315 |
5. As long as any appear, remove a non-dot-dot filename immediately
|
|
|
|
| 349 |
or a pathname in the native format [[fs.class.path]]. Such an argument
|
| 350 |
is taken to be in the generic format if and only if it matches the
|
| 351 |
generic format and is not acceptable to the operating system as a native
|
| 352 |
path.
|
| 353 |
|
| 354 |
+
[*Note 2*: Some operating systems have no unambiguous way to
|
| 355 |
distinguish between native format and generic format arguments. This is
|
| 356 |
by design as it simplifies use for operating systems that do not require
|
| 357 |
disambiguation. An implementation for an operating system where
|
| 358 |
disambiguation is required is permitted to distinguish between the
|
| 359 |
formats. — *end note*]
|
|
|
|
| 372 |
directory path if its last element is a *directory-separator*, otherwise
|
| 373 |
it shall be treated as a path to a regular file.
|
| 374 |
|
| 375 |
[*Note 4*: A path stores a native format pathname
|
| 376 |
[[fs.path.native.obs]] and acts as if it also stores a generic format
|
| 377 |
+
pathname, related as given below. The implementation can generate the
|
| 378 |
generic format pathname based on the native format pathname (and
|
| 379 |
possibly other information) when requested. — *end note*]
|
| 380 |
|
| 381 |
When a path is constructed from or is assigned a single representation
|
| 382 |
separate from any path, the other representation is selected by the
|
|
|
|
| 394 |
|
| 395 |
The *native encoding* of an ordinary character string is the operating
|
| 396 |
system dependent current encoding for pathnames [[fs.class.path]]. The
|
| 397 |
*native encoding* for wide character strings is the
|
| 398 |
implementation-defined execution wide-character set encoding
|
| 399 |
+
[[character.seq]].
|
| 400 |
|
| 401 |
For member function arguments that take character sequences representing
|
| 402 |
paths and for member functions returning strings, value type and
|
| 403 |
encoding conversion is performed if the value type of the argument or
|
| 404 |
return value differs from `path::value_type`. For the argument or return
|
|
|
|
| 412 |
return values is performed. For Windows-based operating systems, the
|
| 413 |
native ordinary encoding is determined by calling a Windows API
|
| 414 |
function. — *end note*] \[*Note 7*: This results in behavior
|
| 415 |
identical to other C and C++ standard library functions that perform
|
| 416 |
file operations using ordinary character strings to identify paths.
|
| 417 |
+
Changing this behavior would be surprising and
|
| 418 |
+
error-prone. — *end note*]
|
| 419 |
- `wchar_t`: The encoding is the native wide encoding. The method of
|
| 420 |
conversion is unspecified. \[*Note 8*: For Windows-based operating
|
| 421 |
systems `path::value_type` is `wchar_t` so no conversion from
|
| 422 |
`wchar_t` value type arguments or to `wchar_t` value type return
|
| 423 |
values is performed. — *end note*]
|
|
|
|
| 461 |
than `path`, and either
|
| 462 |
|
| 463 |
- `Source` is a specialization of `basic_string` or `basic_string_view`,
|
| 464 |
or
|
| 465 |
- the *qualified-id* `iterator_traits<decay_t<Source>>::value_type` is
|
| 466 |
+
valid and denotes a possibly const encoded character type
|
| 467 |
[[temp.deduct]].
|
| 468 |
|
| 469 |
[*Note 1*: See path conversions [[fs.path.cvt]] for how the value types
|
| 470 |
above and their encodings convert to `path::value_type` and its
|
| 471 |
encoding. — *end note*]
|
|
|
|
| 700 |
```
|
| 701 |
|
| 702 |
*Effects:* Appends `path(x).native()` to the pathname in the native
|
| 703 |
format.
|
| 704 |
|
| 705 |
+
[*Note 2*: This directly manipulates the value of `native()`, which is
|
| 706 |
+
not necessarily portable between operating systems. — *end note*]
|
| 707 |
|
| 708 |
*Returns:* `*this`.
|
| 709 |
|
| 710 |
``` cpp
|
| 711 |
path& operator+=(value_type x);
|
|
|
|
| 854 |
operator string_type() const;
|
| 855 |
```
|
| 856 |
|
| 857 |
*Returns:* `native()`.
|
| 858 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 859 |
``` cpp
|
| 860 |
template<class EcharT, class traits = char_traits<EcharT>,
|
| 861 |
class Allocator = allocator<EcharT>>
|
| 862 |
basic_string<EcharT, traits, Allocator>
|
| 863 |
string(const Allocator& a = Allocator()) const;
|
|
|
|
| 1057 |
path("..bar").extension(); // yields ".bar" and stem() is "."
|
| 1058 |
```
|
| 1059 |
|
| 1060 |
— *end example*]
|
| 1061 |
|
| 1062 |
+
[*Note 3*: The period is included in the return value so that it is
|
| 1063 |
possible to distinguish between no extension and an empty
|
| 1064 |
extension. — *end note*]
|
| 1065 |
|
| 1066 |
+
[*Note 4*: On non-POSIX operating systems, for a path `p`, it is
|
| 1067 |
+
possible that `p.stem() + p.extension() == p.filename()` is `false`,
|
| 1068 |
+
even though the generic format pathnames are the same. — *end note*]
|
| 1069 |
|
| 1070 |
##### Query <a id="fs.path.query">[[fs.path.query]]</a>
|
| 1071 |
|
| 1072 |
``` cpp
|
| 1073 |
[[nodiscard]] bool empty() const noexcept;
|
|
|
|
| 1166 |
|
| 1167 |
``` cpp
|
| 1168 |
path lexically_relative(const path& base) const;
|
| 1169 |
```
|
| 1170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1171 |
*Effects:* If:
|
| 1172 |
|
| 1173 |
- `root_name() != base.root_name()` is `true`, or
|
| 1174 |
- `is_absolute() != base.is_absolute()` is `true`, or
|
| 1175 |
- `!has_root_directory() && base.has_root_directory()` is `true`, or
|
| 1176 |
- any *filename* in `relative_path()` or `base.relative_path()` can be
|
| 1177 |
interpreted as a *root-name*,
|
| 1178 |
|
| 1179 |
returns `path()`.
|
| 1180 |
|
| 1181 |
+
[*Note 5*: On a POSIX implementation, no *filename* in a
|
| 1182 |
*relative-path* is acceptable as a *root-name*. — *end note*]
|
| 1183 |
|
| 1184 |
Determines the first mismatched element of `*this` and `base` as if by:
|
| 1185 |
|
| 1186 |
``` cpp
|
|
|
|
| 1198 |
- returns an object of class `path` that is default-constructed,
|
| 1199 |
followed by
|
| 1200 |
- application of `operator/=(path(".."))` `n` times, and then
|
| 1201 |
- application of `operator/=` for each element in \[`a`, `end()`).
|
| 1202 |
|
| 1203 |
+
*Returns:* `*this` made relative to `base`. Does not
|
| 1204 |
+
resolve [[fs.class.path]] symlinks. Does not first
|
| 1205 |
+
normalize [[fs.path.generic]] `*this` or `base`.
|
| 1206 |
+
|
| 1207 |
[*Example 11*:
|
| 1208 |
|
| 1209 |
``` cpp
|
| 1210 |
assert(path("/a/d").lexically_relative("/a/b/c") == "../../d");
|
| 1211 |
assert(path("/a/b/c").lexically_relative("/a/d") == "../b/c");
|
|
|
|
| 1219 |
*directory-separator* characters will be backslashes rather than
|
| 1220 |
slashes, but that does not affect `path` equality.
|
| 1221 |
|
| 1222 |
— *end example*]
|
| 1223 |
|
| 1224 |
+
[*Note 6*: If symlink following semantics are desired, use the
|
| 1225 |
operational function `relative()`. — *end note*]
|
| 1226 |
|
| 1227 |
+
[*Note 7*: If normalization [[fs.path.generic]] is needed to ensure
|
| 1228 |
consistent matching of elements, apply `lexically_normal()` to `*this`,
|
| 1229 |
`base`, or both. — *end note*]
|
| 1230 |
|
| 1231 |
``` cpp
|
| 1232 |
path lexically_proximate(const path& base) const;
|
| 1233 |
```
|
| 1234 |
|
| 1235 |
*Returns:* If the value of `lexically_relative(base)` is not an empty
|
| 1236 |
path, return it. Otherwise return `*this`.
|
| 1237 |
|
| 1238 |
+
[*Note 8*: If symlink following semantics are desired, use the
|
| 1239 |
operational function `proximate()`. — *end note*]
|
| 1240 |
|
| 1241 |
+
[*Note 9*: If normalization [[fs.path.generic]] is needed to ensure
|
| 1242 |
consistent matching of elements, apply `lexically_normal()` to `*this`,
|
| 1243 |
`base`, or both. — *end note*]
|
| 1244 |
|
| 1245 |
#### Iterators <a id="fs.path.itr">[[fs.path.itr]]</a>
|
| 1246 |
|
|
|
|
| 1345 |
- Equivalence is determined by the `equivalent()` non-member function,
|
| 1346 |
which determines if two paths resolve [[fs.class.path]] to the same
|
| 1347 |
file system entity. \[*Example 2*: `equivalent("foo", "bar")` will be
|
| 1348 |
`true` when both paths resolve to the same file. — *end example*]
|
| 1349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1350 |
— *end note*]
|
| 1351 |
|
| 1352 |
``` cpp
|
| 1353 |
friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept;
|
| 1354 |
```
|
|
|
|
| 1359 |
friend path operator/(const path& lhs, const path& rhs);
|
| 1360 |
```
|
| 1361 |
|
| 1362 |
*Effects:* Equivalent to: `return path(lhs) /= rhs;`
|
| 1363 |
|
| 1364 |
+
#### Hash support <a id="fs.path.hash">[[fs.path.hash]]</a>
|
| 1365 |
+
|
| 1366 |
+
``` cpp
|
| 1367 |
+
template<> struct hash<filesystem::path>;
|
| 1368 |
+
```
|
| 1369 |
+
|
| 1370 |
+
For an object `p` of type `filesystem::path`,
|
| 1371 |
+
`hash<filesystem::path>()(p)` evaluates to the same result as
|
| 1372 |
+
`filesystem::hash_value(p)`.
|
| 1373 |
+
|