tmp/tmpi7_xfnpv/{from.md → to.md}
RENAMED
|
@@ -106,11 +106,11 @@ group [[fs.enum.copy.opts]] is set in `options`.
|
|
| 106 |
Effects are then as follows:
|
| 107 |
|
| 108 |
- If `f.type()` or `t.type()` is an implementation-defined file
|
| 109 |
type [[fs.enum.file.type]], then the effects are
|
| 110 |
*implementation-defined*.
|
| 111 |
-
- Otherwise, an error is reported as specified in [[fs.err.report]] if
|
| 112 |
- `exists(f)` is `false`, or
|
| 113 |
- `equivalent(from, to)` is `true`, or
|
| 114 |
- `is_other(f) || is_other(t)` is `true`, or
|
| 115 |
- `is_directory(f) && is_regular_file(t)` is `true`.
|
| 116 |
- Otherwise, if `is_symlink(f)`, then:
|
|
@@ -173,21 +173,21 @@ applicable.
|
|
| 173 |
|
| 174 |
[*Example 1*:
|
| 175 |
|
| 176 |
Given this directory structure:
|
| 177 |
|
| 178 |
-
```
|
| 179 |
/dir1
|
| 180 |
file1
|
| 181 |
file2
|
| 182 |
dir2
|
| 183 |
file3
|
| 184 |
```
|
| 185 |
|
| 186 |
Calling `copy("/dir1", "/dir3")` would result in:
|
| 187 |
|
| 188 |
-
```
|
| 189 |
/dir1
|
| 190 |
file1
|
| 191 |
file2
|
| 192 |
dir2
|
| 193 |
file3
|
|
@@ -197,11 +197,11 @@ Calling `copy("/dir1", "/dir3")` would result in:
|
|
| 197 |
```
|
| 198 |
|
| 199 |
Alternatively, calling `copy("/dir1", "/dir3", copy_options::recursive)`
|
| 200 |
would result in:
|
| 201 |
|
| 202 |
-
```
|
| 203 |
/dir1
|
| 204 |
file1
|
| 205 |
file2
|
| 206 |
dir2
|
| 207 |
file3
|
|
@@ -235,22 +235,22 @@ bool filesystem::copy_file(const path& from, const path& to, copy_options option
|
|
| 235 |
*Preconditions:* At most one element from each option
|
| 236 |
group [[fs.enum.copy.opts]] is set in `options`.
|
| 237 |
|
| 238 |
*Effects:* As follows:
|
| 239 |
|
| 240 |
-
- Report an error as specified in [[fs.err.report]] if
|
| 241 |
- `is_regular_file(from)` is `false`, or
|
| 242 |
- `exists(to)` is `true` and `is_regular_file(to)` is `false`, or
|
| 243 |
- `exists(to)` is `true` and `equivalent(from, to)` is `true`, or
|
| 244 |
- `exists(to)` is `true` and
|
| 245 |
``` cpp
|
| 246 |
(options & (copy_options::skip_existing |
|
| 247 |
copy_options::overwrite_existing |
|
| 248 |
copy_options::update_existing)) == copy_options::none
|
| 249 |
```
|
| 250 |
- Otherwise, copy the contents and attributes of the file `from`
|
| 251 |
-
resolves to, to the file `to` resolves to, if
|
| 252 |
- `exists(to)` is `false`, or
|
| 253 |
- `(options & copy_options::overwrite_existing) != copy_options::none`,
|
| 254 |
or
|
| 255 |
- `(options & copy_options::update_existing) `` `` != copy_options::none`
|
| 256 |
and `from` is more recent than `to`, determined as if by use of the
|
|
@@ -285,11 +285,11 @@ respectively, where in each case *`function`* is `create_symlink` or
|
|
| 285 |
``` cpp
|
| 286 |
bool filesystem::create_directories(const path& p);
|
| 287 |
bool filesystem::create_directories(const path& p, error_code& ec);
|
| 288 |
```
|
| 289 |
|
| 290 |
-
*Effects:* Calls `create_directory
|
| 291 |
not exist.
|
| 292 |
|
| 293 |
*Returns:* `true` if a new directory was created for the directory `p`
|
| 294 |
resolves to, otherwise `false`.
|
| 295 |
|
|
@@ -342,21 +342,21 @@ from directory `existing_p`, otherwise `false`.
|
|
| 342 |
void filesystem::create_directory_symlink(const path& to, const path& new_symlink);
|
| 343 |
void filesystem::create_directory_symlink(const path& to, const path& new_symlink,
|
| 344 |
error_code& ec) noexcept;
|
| 345 |
```
|
| 346 |
|
| 347 |
-
*Effects:* Establishes the postcondition, as if by POSIX `symlink
|
| 348 |
|
| 349 |
*Ensures:* `new_symlink` resolves to a symbolic link file that contains
|
| 350 |
an unspecified representation of `to`.
|
| 351 |
|
| 352 |
*Throws:* As specified in [[fs.err.report]].
|
| 353 |
|
| 354 |
[*Note 1*: Some operating systems require symlink creation to identify
|
| 355 |
-
that the link is to a directory. Thus, `create_symlink
|
| 356 |
-
`create_directory_symlink
|
| 357 |
-
|
| 358 |
|
| 359 |
[*Note 2*: Some operating systems do not support symbolic links at all
|
| 360 |
or support them only for regular files. Some file systems (such as the
|
| 361 |
FAT file system) do not support symbolic links regardless of the
|
| 362 |
operating system. — *end note*]
|
|
@@ -367,11 +367,11 @@ operating system. — *end note*]
|
|
| 367 |
void filesystem::create_hard_link(const path& to, const path& new_hard_link);
|
| 368 |
void filesystem::create_hard_link(const path& to, const path& new_hard_link,
|
| 369 |
error_code& ec) noexcept;
|
| 370 |
```
|
| 371 |
|
| 372 |
-
*Effects:* Establishes the postcondition, as if by POSIX `link
|
| 373 |
|
| 374 |
*Ensures:*
|
| 375 |
|
| 376 |
- `exists(to) && exists(new_hard_link) && equivalent(to, new_hard_link)`
|
| 377 |
- The contents of the file or directory `to` resolves to are unchanged.
|
|
@@ -390,11 +390,11 @@ file. — *end note*]
|
|
| 390 |
void filesystem::create_symlink(const path& to, const path& new_symlink);
|
| 391 |
void filesystem::create_symlink(const path& to, const path& new_symlink,
|
| 392 |
error_code& ec) noexcept;
|
| 393 |
```
|
| 394 |
|
| 395 |
-
*Effects:* Establishes the postcondition, as if by POSIX `symlink
|
| 396 |
|
| 397 |
*Ensures:* `new_symlink` resolves to a symbolic link file that contains
|
| 398 |
an unspecified representation of `to`.
|
| 399 |
|
| 400 |
*Throws:* As specified in [[fs.err.report]].
|
|
@@ -410,39 +410,35 @@ operating system. — *end note*]
|
|
| 410 |
path filesystem::current_path();
|
| 411 |
path filesystem::current_path(error_code& ec);
|
| 412 |
```
|
| 413 |
|
| 414 |
*Returns:* The absolute path of the current working directory, whose
|
| 415 |
-
pathname in the native format is obtained as if by POSIX `getcwd
|
| 416 |
signature with argument `ec` returns `path()` if an error occurs.
|
| 417 |
|
| 418 |
*Throws:* As specified in [[fs.err.report]].
|
| 419 |
|
| 420 |
*Remarks:* The current working directory is the directory, associated
|
| 421 |
with the process, that is used as the starting location in pathname
|
| 422 |
resolution for relative paths.
|
| 423 |
|
| 424 |
-
[*Note 1*: The
|
| 425 |
-
returned value is a path, not just a single directory
|
| 426 |
-
name. — *end note*]
|
| 427 |
-
|
| 428 |
-
[*Note 2*: The current path as returned by many operating systems is a
|
| 429 |
dangerous global variable and can be changed unexpectedly by third-party
|
| 430 |
or system library functions, or by another thread. — *end note*]
|
| 431 |
|
| 432 |
``` cpp
|
| 433 |
void filesystem::current_path(const path& p);
|
| 434 |
void filesystem::current_path(const path& p, error_code& ec) noexcept;
|
| 435 |
```
|
| 436 |
|
| 437 |
-
*Effects:* Establishes the postcondition, as if by POSIX `chdir
|
| 438 |
|
| 439 |
*Ensures:* `equivalent(p, current_path())`.
|
| 440 |
|
| 441 |
*Throws:* As specified in [[fs.err.report]].
|
| 442 |
|
| 443 |
-
[*Note
|
| 444 |
global state and can be changed unexpectedly by third-party or system
|
| 445 |
library functions, or by another thread. — *end note*]
|
| 446 |
|
| 447 |
#### Equivalent <a id="fs.op.equivalent">[[fs.op.equivalent]]</a>
|
| 448 |
|
|
@@ -453,11 +449,11 @@ bool filesystem::equivalent(const path& p1, const path& p2, error_code& ec) noex
|
|
| 453 |
|
| 454 |
Two paths are considered to resolve to the same file system entity if
|
| 455 |
two candidate entities reside on the same device at the same location.
|
| 456 |
|
| 457 |
[*Note 1*: On POSIX platforms, this is determined as if by the values
|
| 458 |
-
of the POSIX `stat` class, obtained as if by `stat
|
| 459 |
having equal `st_dev` values and equal `st_ino` values. — *end note*]
|
| 460 |
|
| 461 |
*Returns:* `true`, if `p1` and `p2` resolve to the same file system
|
| 462 |
entity, otherwise `false`. The signature with argument `ec` returns
|
| 463 |
`false` if an error occurs.
|
|
@@ -501,11 +497,11 @@ reported [[fs.err.report]].
|
|
| 501 |
|
| 502 |
*Returns:*
|
| 503 |
|
| 504 |
- If `is_regular_file(p)`, the size in bytes of the file `p` resolves
|
| 505 |
to, determined as if by the value of the POSIX `stat` class member
|
| 506 |
-
`st_size` obtained as if by POSIX `stat
|
| 507 |
- Otherwise, the result is *implementation-defined*.
|
| 508 |
|
| 509 |
The signature with argument `ec` returns `static_cast<uintmax_t>(-1)` if
|
| 510 |
an error occurs.
|
| 511 |
|
|
@@ -722,11 +718,11 @@ file_time_type filesystem::last_write_time(const path& p);
|
|
| 722 |
file_time_type filesystem::last_write_time(const path& p, error_code& ec) noexcept;
|
| 723 |
```
|
| 724 |
|
| 725 |
*Returns:* The time of last data modification of `p`, determined as if
|
| 726 |
by the value of the POSIX `stat` class member `st_mtime` obtained as if
|
| 727 |
-
by POSIX `stat
|
| 728 |
`file_time_type::min()` if an error occurs.
|
| 729 |
|
| 730 |
*Throws:* As specified in [[fs.err.report]].
|
| 731 |
|
| 732 |
``` cpp
|
|
@@ -734,11 +730,11 @@ void filesystem::last_write_time(const path& p, file_time_type new_time);
|
|
| 734 |
void filesystem::last_write_time(const path& p, file_time_type new_time,
|
| 735 |
error_code& ec) noexcept;
|
| 736 |
```
|
| 737 |
|
| 738 |
*Effects:* Sets the time of last data modification of the file resolved
|
| 739 |
-
to by `p` to `new_time`, as if by POSIX `futimens
|
| 740 |
|
| 741 |
*Throws:* As specified in [[fs.err.report]].
|
| 742 |
|
| 743 |
[*Note 1*: A postcondition of `last_write_time(p) == new_time` is not
|
| 744 |
specified because it does not necessarily hold for file systems with
|
|
@@ -756,11 +752,11 @@ void filesystem::permissions(const path& p, perms prms, perm_options opts, error
|
|
| 756 |
`add`, or `remove` is present in `opts`.
|
| 757 |
|
| 758 |
*Effects:* Applies the action specified by `opts` to the file `p`
|
| 759 |
resolves to, or to file `p` itself if `p` is a symbolic link and
|
| 760 |
`perm_options::nofollow` is set in `opts`. The action is applied as if
|
| 761 |
-
by POSIX `fchmodat
|
| 762 |
|
| 763 |
[*Note 1*: Conceptually permissions are viewed as bits, but the actual
|
| 764 |
implementation can use some other mechanism. — *end note*]
|
| 765 |
|
| 766 |
*Throws:* As specified in [[fs.err.report]].
|
|
@@ -853,19 +849,20 @@ or `path()` at the first error occurrence, if any.
|
|
| 853 |
bool filesystem::remove(const path& p);
|
| 854 |
bool filesystem::remove(const path& p, error_code& ec) noexcept;
|
| 855 |
```
|
| 856 |
|
| 857 |
*Effects:* If `exists(symlink_status(p, ec))`, the file `p` is removed
|
| 858 |
-
as if by POSIX `remove
|
| 859 |
|
| 860 |
[*Note 1*: A symbolic link is itself removed, rather than the file it
|
| 861 |
resolves to. — *end note*]
|
| 862 |
|
| 863 |
*Ensures:* `exists(symlink_status(p))` is `false`.
|
| 864 |
|
| 865 |
-
*Returns:* `
|
| 866 |
-
|
|
|
|
| 867 |
|
| 868 |
*Throws:* As specified in [[fs.err.report]].
|
| 869 |
|
| 870 |
#### Remove all <a id="fs.op.remove.all">[[fs.op.remove.all]]</a>
|
| 871 |
|
|
@@ -873,11 +870,11 @@ with argument `ec` returns `false` if an error occurs.
|
|
| 873 |
uintmax_t filesystem::remove_all(const path& p);
|
| 874 |
uintmax_t filesystem::remove_all(const path& p, error_code& ec);
|
| 875 |
```
|
| 876 |
|
| 877 |
*Effects:* Recursively deletes the contents of `p` if it exists, then
|
| 878 |
-
deletes file `p` itself, as if by POSIX `remove
|
| 879 |
|
| 880 |
[*Note 1*: A symbolic link is itself removed, rather than the file it
|
| 881 |
resolves to. — *end note*]
|
| 882 |
|
| 883 |
*Ensures:* `exists(symlink_status(p))` is `false`.
|
|
@@ -892,11 +889,11 @@ returns `static_cast< uintmax_t>(-1)` if an error occurs.
|
|
| 892 |
``` cpp
|
| 893 |
void filesystem::rename(const path& old_p, const path& new_p);
|
| 894 |
void filesystem::rename(const path& old_p, const path& new_p, error_code& ec) noexcept;
|
| 895 |
```
|
| 896 |
|
| 897 |
-
*Effects:* Renames `old_p` to `new_p`, as if by POSIX `rename
|
| 898 |
|
| 899 |
[*Note 1*:
|
| 900 |
|
| 901 |
- If `old_p` and `new_p` resolve to the same existing file, no action is
|
| 902 |
taken.
|
|
@@ -919,11 +916,11 @@ A symbolic link is itself renamed, rather than the file it resolves to.
|
|
| 919 |
void filesystem::resize_file(const path& p, uintmax_t new_size);
|
| 920 |
void filesystem::resize_file(const path& p, uintmax_t new_size, error_code& ec) noexcept;
|
| 921 |
```
|
| 922 |
|
| 923 |
*Effects:* Causes the size that would be returned by `file_size(p)` to
|
| 924 |
-
be equal to `new_size`, as if by POSIX `truncate
|
| 925 |
|
| 926 |
*Throws:* As specified in [[fs.err.report]].
|
| 927 |
|
| 928 |
#### Space <a id="fs.op.space">[[fs.op.space]]</a>
|
| 929 |
|
|
@@ -952,11 +949,11 @@ system dependent.
|
|
| 952 |
|
| 953 |
``` cpp
|
| 954 |
file_status filesystem::status(const path& p);
|
| 955 |
```
|
| 956 |
|
| 957 |
-
*Effects:* As if:
|
| 958 |
|
| 959 |
``` cpp
|
| 960 |
error_code ec;
|
| 961 |
file_status result = status(p, ec);
|
| 962 |
if (result.type() == file_type::none)
|
|
@@ -975,17 +972,17 @@ cause an exception to be thrown. — *end note*]
|
|
| 975 |
``` cpp
|
| 976 |
file_status filesystem::status(const path& p, error_code& ec) noexcept;
|
| 977 |
```
|
| 978 |
|
| 979 |
*Effects:* If possible, determines the attributes of the file `p`
|
| 980 |
-
resolves to, as if by using POSIX `stat
|
| 981 |
`struct stat`. If, during attribute determination, the underlying file
|
| 982 |
system API reports an error, sets `ec` to indicate the specific error
|
| 983 |
reported. Otherwise, `ec.clear()`.
|
| 984 |
|
| 985 |
[*Note 2*: This allows users to inspect the specifics of underlying API
|
| 986 |
-
errors even when the value returned by `status
|
| 987 |
`file_status(file_type::none)`. — *end note*]
|
| 988 |
|
| 989 |
Let `prms` denote the result of `(m & perms::mask)`, where `m` is
|
| 990 |
determined as if by converting the `st_mode` member of the obtained
|
| 991 |
`struct stat` to the type `perms`.
|
|
@@ -1048,19 +1045,19 @@ bool filesystem::status_known(file_status s) noexcept;
|
|
| 1048 |
``` cpp
|
| 1049 |
file_status filesystem::symlink_status(const path& p);
|
| 1050 |
file_status filesystem::symlink_status(const path& p, error_code& ec) noexcept;
|
| 1051 |
```
|
| 1052 |
|
| 1053 |
-
*Effects:* Same as `status
|
| 1054 |
-
are determined as if by using POSIX `lstat
|
| 1055 |
`struct stat`.
|
| 1056 |
|
| 1057 |
Let `prms` denote the result of `(m & perms::mask)`, where `m` is
|
| 1058 |
determined as if by converting the `st_mode` member of the obtained
|
| 1059 |
`struct stat` to the type `perms`.
|
| 1060 |
|
| 1061 |
-
*Returns:* Same as `status
|
| 1062 |
indicate a symbolic link, as if by POSIX `S_ISLNK`, returns
|
| 1063 |
`file_status(file_type::symlink, prms)`. The signature with argument
|
| 1064 |
`ec` returns `file_status(file_type::none)` if an error occurs.
|
| 1065 |
|
| 1066 |
*Throws:* As specified in [[fs.err.report]].
|
|
@@ -1098,16 +1095,16 @@ path filesystem::weakly_canonical(const path& p);
|
|
| 1098 |
path filesystem::weakly_canonical(const path& p, error_code& ec);
|
| 1099 |
```
|
| 1100 |
|
| 1101 |
*Effects:* Using `status(p)` or `status(p, ec)`, respectively, to
|
| 1102 |
determine existence, return a path composed by `operator/=` from the
|
| 1103 |
-
result of calling `canonical
|
| 1104 |
leading elements of `p` that exist, if any, followed by the elements of
|
| 1105 |
-
`p` that do not exist, if any. For the first form, `canonical
|
| 1106 |
-
|
| 1107 |
-
|
| 1108 |
-
|
| 1109 |
|
| 1110 |
*Ensures:* The returned path is in normal form [[fs.path.generic]].
|
| 1111 |
|
| 1112 |
*Returns:* `p` with symlinks resolved and the result
|
| 1113 |
normalized [[fs.path.generic]].
|
|
|
|
| 106 |
Effects are then as follows:
|
| 107 |
|
| 108 |
- If `f.type()` or `t.type()` is an implementation-defined file
|
| 109 |
type [[fs.enum.file.type]], then the effects are
|
| 110 |
*implementation-defined*.
|
| 111 |
+
- Otherwise, an error is reported as specified in [[fs.err.report]] if
|
| 112 |
- `exists(f)` is `false`, or
|
| 113 |
- `equivalent(from, to)` is `true`, or
|
| 114 |
- `is_other(f) || is_other(t)` is `true`, or
|
| 115 |
- `is_directory(f) && is_regular_file(t)` is `true`.
|
| 116 |
- Otherwise, if `is_symlink(f)`, then:
|
|
|
|
| 173 |
|
| 174 |
[*Example 1*:
|
| 175 |
|
| 176 |
Given this directory structure:
|
| 177 |
|
| 178 |
+
``` text
|
| 179 |
/dir1
|
| 180 |
file1
|
| 181 |
file2
|
| 182 |
dir2
|
| 183 |
file3
|
| 184 |
```
|
| 185 |
|
| 186 |
Calling `copy("/dir1", "/dir3")` would result in:
|
| 187 |
|
| 188 |
+
``` text
|
| 189 |
/dir1
|
| 190 |
file1
|
| 191 |
file2
|
| 192 |
dir2
|
| 193 |
file3
|
|
|
|
| 197 |
```
|
| 198 |
|
| 199 |
Alternatively, calling `copy("/dir1", "/dir3", copy_options::recursive)`
|
| 200 |
would result in:
|
| 201 |
|
| 202 |
+
``` text
|
| 203 |
/dir1
|
| 204 |
file1
|
| 205 |
file2
|
| 206 |
dir2
|
| 207 |
file3
|
|
|
|
| 235 |
*Preconditions:* At most one element from each option
|
| 236 |
group [[fs.enum.copy.opts]] is set in `options`.
|
| 237 |
|
| 238 |
*Effects:* As follows:
|
| 239 |
|
| 240 |
+
- Report an error as specified in [[fs.err.report]] if
|
| 241 |
- `is_regular_file(from)` is `false`, or
|
| 242 |
- `exists(to)` is `true` and `is_regular_file(to)` is `false`, or
|
| 243 |
- `exists(to)` is `true` and `equivalent(from, to)` is `true`, or
|
| 244 |
- `exists(to)` is `true` and
|
| 245 |
``` cpp
|
| 246 |
(options & (copy_options::skip_existing |
|
| 247 |
copy_options::overwrite_existing |
|
| 248 |
copy_options::update_existing)) == copy_options::none
|
| 249 |
```
|
| 250 |
- Otherwise, copy the contents and attributes of the file `from`
|
| 251 |
+
resolves to, to the file `to` resolves to, if
|
| 252 |
- `exists(to)` is `false`, or
|
| 253 |
- `(options & copy_options::overwrite_existing) != copy_options::none`,
|
| 254 |
or
|
| 255 |
- `(options & copy_options::update_existing) `` `` != copy_options::none`
|
| 256 |
and `from` is more recent than `to`, determined as if by use of the
|
|
|
|
| 285 |
``` cpp
|
| 286 |
bool filesystem::create_directories(const path& p);
|
| 287 |
bool filesystem::create_directories(const path& p, error_code& ec);
|
| 288 |
```
|
| 289 |
|
| 290 |
+
*Effects:* Calls `create_directory` for each element of `p` that does
|
| 291 |
not exist.
|
| 292 |
|
| 293 |
*Returns:* `true` if a new directory was created for the directory `p`
|
| 294 |
resolves to, otherwise `false`.
|
| 295 |
|
|
|
|
| 342 |
void filesystem::create_directory_symlink(const path& to, const path& new_symlink);
|
| 343 |
void filesystem::create_directory_symlink(const path& to, const path& new_symlink,
|
| 344 |
error_code& ec) noexcept;
|
| 345 |
```
|
| 346 |
|
| 347 |
+
*Effects:* Establishes the postcondition, as if by POSIX `symlink`.
|
| 348 |
|
| 349 |
*Ensures:* `new_symlink` resolves to a symbolic link file that contains
|
| 350 |
an unspecified representation of `to`.
|
| 351 |
|
| 352 |
*Throws:* As specified in [[fs.err.report]].
|
| 353 |
|
| 354 |
[*Note 1*: Some operating systems require symlink creation to identify
|
| 355 |
+
that the link is to a directory. Thus, `create_symlink` (instead of
|
| 356 |
+
`create_directory_symlink`) cannot be used reliably to create directory
|
| 357 |
+
symlinks. — *end note*]
|
| 358 |
|
| 359 |
[*Note 2*: Some operating systems do not support symbolic links at all
|
| 360 |
or support them only for regular files. Some file systems (such as the
|
| 361 |
FAT file system) do not support symbolic links regardless of the
|
| 362 |
operating system. — *end note*]
|
|
|
|
| 367 |
void filesystem::create_hard_link(const path& to, const path& new_hard_link);
|
| 368 |
void filesystem::create_hard_link(const path& to, const path& new_hard_link,
|
| 369 |
error_code& ec) noexcept;
|
| 370 |
```
|
| 371 |
|
| 372 |
+
*Effects:* Establishes the postcondition, as if by POSIX `link`.
|
| 373 |
|
| 374 |
*Ensures:*
|
| 375 |
|
| 376 |
- `exists(to) && exists(new_hard_link) && equivalent(to, new_hard_link)`
|
| 377 |
- The contents of the file or directory `to` resolves to are unchanged.
|
|
|
|
| 390 |
void filesystem::create_symlink(const path& to, const path& new_symlink);
|
| 391 |
void filesystem::create_symlink(const path& to, const path& new_symlink,
|
| 392 |
error_code& ec) noexcept;
|
| 393 |
```
|
| 394 |
|
| 395 |
+
*Effects:* Establishes the postcondition, as if by POSIX `symlink`.
|
| 396 |
|
| 397 |
*Ensures:* `new_symlink` resolves to a symbolic link file that contains
|
| 398 |
an unspecified representation of `to`.
|
| 399 |
|
| 400 |
*Throws:* As specified in [[fs.err.report]].
|
|
|
|
| 410 |
path filesystem::current_path();
|
| 411 |
path filesystem::current_path(error_code& ec);
|
| 412 |
```
|
| 413 |
|
| 414 |
*Returns:* The absolute path of the current working directory, whose
|
| 415 |
+
pathname in the native format is obtained as if by POSIX `getcwd`. The
|
| 416 |
signature with argument `ec` returns `path()` if an error occurs.
|
| 417 |
|
| 418 |
*Throws:* As specified in [[fs.err.report]].
|
| 419 |
|
| 420 |
*Remarks:* The current working directory is the directory, associated
|
| 421 |
with the process, that is used as the starting location in pathname
|
| 422 |
resolution for relative paths.
|
| 423 |
|
| 424 |
+
[*Note 1*: The current path as returned by many operating systems is a
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
dangerous global variable and can be changed unexpectedly by third-party
|
| 426 |
or system library functions, or by another thread. — *end note*]
|
| 427 |
|
| 428 |
``` cpp
|
| 429 |
void filesystem::current_path(const path& p);
|
| 430 |
void filesystem::current_path(const path& p, error_code& ec) noexcept;
|
| 431 |
```
|
| 432 |
|
| 433 |
+
*Effects:* Establishes the postcondition, as if by POSIX `chdir`.
|
| 434 |
|
| 435 |
*Ensures:* `equivalent(p, current_path())`.
|
| 436 |
|
| 437 |
*Throws:* As specified in [[fs.err.report]].
|
| 438 |
|
| 439 |
+
[*Note 2*: The current path for many operating systems is a dangerous
|
| 440 |
global state and can be changed unexpectedly by third-party or system
|
| 441 |
library functions, or by another thread. — *end note*]
|
| 442 |
|
| 443 |
#### Equivalent <a id="fs.op.equivalent">[[fs.op.equivalent]]</a>
|
| 444 |
|
|
|
|
| 449 |
|
| 450 |
Two paths are considered to resolve to the same file system entity if
|
| 451 |
two candidate entities reside on the same device at the same location.
|
| 452 |
|
| 453 |
[*Note 1*: On POSIX platforms, this is determined as if by the values
|
| 454 |
+
of the POSIX `stat` class, obtained as if by `stat` for the two paths,
|
| 455 |
having equal `st_dev` values and equal `st_ino` values. — *end note*]
|
| 456 |
|
| 457 |
*Returns:* `true`, if `p1` and `p2` resolve to the same file system
|
| 458 |
entity, otherwise `false`. The signature with argument `ec` returns
|
| 459 |
`false` if an error occurs.
|
|
|
|
| 497 |
|
| 498 |
*Returns:*
|
| 499 |
|
| 500 |
- If `is_regular_file(p)`, the size in bytes of the file `p` resolves
|
| 501 |
to, determined as if by the value of the POSIX `stat` class member
|
| 502 |
+
`st_size` obtained as if by POSIX `stat`.
|
| 503 |
- Otherwise, the result is *implementation-defined*.
|
| 504 |
|
| 505 |
The signature with argument `ec` returns `static_cast<uintmax_t>(-1)` if
|
| 506 |
an error occurs.
|
| 507 |
|
|
|
|
| 718 |
file_time_type filesystem::last_write_time(const path& p, error_code& ec) noexcept;
|
| 719 |
```
|
| 720 |
|
| 721 |
*Returns:* The time of last data modification of `p`, determined as if
|
| 722 |
by the value of the POSIX `stat` class member `st_mtime` obtained as if
|
| 723 |
+
by POSIX `stat`. The signature with argument `ec` returns
|
| 724 |
`file_time_type::min()` if an error occurs.
|
| 725 |
|
| 726 |
*Throws:* As specified in [[fs.err.report]].
|
| 727 |
|
| 728 |
``` cpp
|
|
|
|
| 730 |
void filesystem::last_write_time(const path& p, file_time_type new_time,
|
| 731 |
error_code& ec) noexcept;
|
| 732 |
```
|
| 733 |
|
| 734 |
*Effects:* Sets the time of last data modification of the file resolved
|
| 735 |
+
to by `p` to `new_time`, as if by POSIX `futimens`.
|
| 736 |
|
| 737 |
*Throws:* As specified in [[fs.err.report]].
|
| 738 |
|
| 739 |
[*Note 1*: A postcondition of `last_write_time(p) == new_time` is not
|
| 740 |
specified because it does not necessarily hold for file systems with
|
|
|
|
| 752 |
`add`, or `remove` is present in `opts`.
|
| 753 |
|
| 754 |
*Effects:* Applies the action specified by `opts` to the file `p`
|
| 755 |
resolves to, or to file `p` itself if `p` is a symbolic link and
|
| 756 |
`perm_options::nofollow` is set in `opts`. The action is applied as if
|
| 757 |
+
by POSIX `fchmodat`.
|
| 758 |
|
| 759 |
[*Note 1*: Conceptually permissions are viewed as bits, but the actual
|
| 760 |
implementation can use some other mechanism. — *end note*]
|
| 761 |
|
| 762 |
*Throws:* As specified in [[fs.err.report]].
|
|
|
|
| 849 |
bool filesystem::remove(const path& p);
|
| 850 |
bool filesystem::remove(const path& p, error_code& ec) noexcept;
|
| 851 |
```
|
| 852 |
|
| 853 |
*Effects:* If `exists(symlink_status(p, ec))`, the file `p` is removed
|
| 854 |
+
as if by POSIX `remove`.
|
| 855 |
|
| 856 |
[*Note 1*: A symbolic link is itself removed, rather than the file it
|
| 857 |
resolves to. — *end note*]
|
| 858 |
|
| 859 |
*Ensures:* `exists(symlink_status(p))` is `false`.
|
| 860 |
|
| 861 |
+
*Returns:* `true` if a file `p` has been removed and `false` otherwise.
|
| 862 |
+
|
| 863 |
+
[*Note 2*: Absence of a file `p` is not an error. — *end note*]
|
| 864 |
|
| 865 |
*Throws:* As specified in [[fs.err.report]].
|
| 866 |
|
| 867 |
#### Remove all <a id="fs.op.remove.all">[[fs.op.remove.all]]</a>
|
| 868 |
|
|
|
|
| 870 |
uintmax_t filesystem::remove_all(const path& p);
|
| 871 |
uintmax_t filesystem::remove_all(const path& p, error_code& ec);
|
| 872 |
```
|
| 873 |
|
| 874 |
*Effects:* Recursively deletes the contents of `p` if it exists, then
|
| 875 |
+
deletes file `p` itself, as if by POSIX `remove`.
|
| 876 |
|
| 877 |
[*Note 1*: A symbolic link is itself removed, rather than the file it
|
| 878 |
resolves to. — *end note*]
|
| 879 |
|
| 880 |
*Ensures:* `exists(symlink_status(p))` is `false`.
|
|
|
|
| 889 |
``` cpp
|
| 890 |
void filesystem::rename(const path& old_p, const path& new_p);
|
| 891 |
void filesystem::rename(const path& old_p, const path& new_p, error_code& ec) noexcept;
|
| 892 |
```
|
| 893 |
|
| 894 |
+
*Effects:* Renames `old_p` to `new_p`, as if by POSIX `rename`.
|
| 895 |
|
| 896 |
[*Note 1*:
|
| 897 |
|
| 898 |
- If `old_p` and `new_p` resolve to the same existing file, no action is
|
| 899 |
taken.
|
|
|
|
| 916 |
void filesystem::resize_file(const path& p, uintmax_t new_size);
|
| 917 |
void filesystem::resize_file(const path& p, uintmax_t new_size, error_code& ec) noexcept;
|
| 918 |
```
|
| 919 |
|
| 920 |
*Effects:* Causes the size that would be returned by `file_size(p)` to
|
| 921 |
+
be equal to `new_size`, as if by POSIX `truncate`.
|
| 922 |
|
| 923 |
*Throws:* As specified in [[fs.err.report]].
|
| 924 |
|
| 925 |
#### Space <a id="fs.op.space">[[fs.op.space]]</a>
|
| 926 |
|
|
|
|
| 949 |
|
| 950 |
``` cpp
|
| 951 |
file_status filesystem::status(const path& p);
|
| 952 |
```
|
| 953 |
|
| 954 |
+
*Effects:* As if by:
|
| 955 |
|
| 956 |
``` cpp
|
| 957 |
error_code ec;
|
| 958 |
file_status result = status(p, ec);
|
| 959 |
if (result.type() == file_type::none)
|
|
|
|
| 972 |
``` cpp
|
| 973 |
file_status filesystem::status(const path& p, error_code& ec) noexcept;
|
| 974 |
```
|
| 975 |
|
| 976 |
*Effects:* If possible, determines the attributes of the file `p`
|
| 977 |
+
resolves to, as if by using POSIX `stat` to obtain a POSIX
|
| 978 |
`struct stat`. If, during attribute determination, the underlying file
|
| 979 |
system API reports an error, sets `ec` to indicate the specific error
|
| 980 |
reported. Otherwise, `ec.clear()`.
|
| 981 |
|
| 982 |
[*Note 2*: This allows users to inspect the specifics of underlying API
|
| 983 |
+
errors even when the value returned by `status` is not
|
| 984 |
`file_status(file_type::none)`. — *end note*]
|
| 985 |
|
| 986 |
Let `prms` denote the result of `(m & perms::mask)`, where `m` is
|
| 987 |
determined as if by converting the `st_mode` member of the obtained
|
| 988 |
`struct stat` to the type `perms`.
|
|
|
|
| 1045 |
``` cpp
|
| 1046 |
file_status filesystem::symlink_status(const path& p);
|
| 1047 |
file_status filesystem::symlink_status(const path& p, error_code& ec) noexcept;
|
| 1048 |
```
|
| 1049 |
|
| 1050 |
+
*Effects:* Same as `status`, above, except that the attributes of `p`
|
| 1051 |
+
are determined as if by using POSIX `lstat` to obtain a POSIX
|
| 1052 |
`struct stat`.
|
| 1053 |
|
| 1054 |
Let `prms` denote the result of `(m & perms::mask)`, where `m` is
|
| 1055 |
determined as if by converting the `st_mode` member of the obtained
|
| 1056 |
`struct stat` to the type `perms`.
|
| 1057 |
|
| 1058 |
+
*Returns:* Same as `status`, above, except that if the attributes
|
| 1059 |
indicate a symbolic link, as if by POSIX `S_ISLNK`, returns
|
| 1060 |
`file_status(file_type::symlink, prms)`. The signature with argument
|
| 1061 |
`ec` returns `file_status(file_type::none)` if an error occurs.
|
| 1062 |
|
| 1063 |
*Throws:* As specified in [[fs.err.report]].
|
|
|
|
| 1095 |
path filesystem::weakly_canonical(const path& p, error_code& ec);
|
| 1096 |
```
|
| 1097 |
|
| 1098 |
*Effects:* Using `status(p)` or `status(p, ec)`, respectively, to
|
| 1099 |
determine existence, return a path composed by `operator/=` from the
|
| 1100 |
+
result of calling `canonical` with a path argument composed of the
|
| 1101 |
leading elements of `p` that exist, if any, followed by the elements of
|
| 1102 |
+
`p` that do not exist, if any. For the first form, `canonical` is called
|
| 1103 |
+
without an `error_code` argument. For the second form, `canonical` is
|
| 1104 |
+
called with `ec` as an `error_code` argument, and `path()` is returned
|
| 1105 |
+
at the first error occurrence, if any.
|
| 1106 |
|
| 1107 |
*Ensures:* The returned path is in normal form [[fs.path.generic]].
|
| 1108 |
|
| 1109 |
*Returns:* `p` with symlinks resolved and the result
|
| 1110 |
normalized [[fs.path.generic]].
|