From Jason Turner

[fs.op.funcs]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp11mzic0k/{from.md → to.md} +1121 -0
tmp/tmp11mzic0k/{from.md → to.md} RENAMED
@@ -0,0 +1,1121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Filesystem operation functions <a id="fs.op.funcs">[[fs.op.funcs]]</a>
2
+
3
+ Filesystem operation functions query or modify files, including
4
+ directories, in external storage.
5
+
6
+ [*Note 1*: Because hardware failures, network failures, file system
7
+ races ([[fs.def.race]]), and many other kinds of errors occur
8
+ frequently in file system operations, users should be aware that any
9
+ filesystem operation function, no matter how apparently innocuous, may
10
+ encounter an error; see  [[fs.err.report]]. — *end note*]
11
+
12
+ #### Absolute <a id="fs.op.absolute">[[fs.op.absolute]]</a>
13
+
14
+ ``` cpp
15
+ path absolute(const path& p);
16
+ path absolute(const path& p, error_code& ec);
17
+ ```
18
+
19
+ *Effects:* Composes an absolute path referencing the same file system
20
+ location as `p` according to the operating system ([[fs.conform.os]]).
21
+
22
+ *Returns:* The composed path. The signature with argument `ec` returns
23
+ `path()` if an error occurs.
24
+
25
+ [*Note 1*: For the returned path, `rp`, `rp.is_absolute()` is `true`
26
+ unless an error occurs. — *end note*]
27
+
28
+ *Throws:* As specified in  [[fs.err.report]].
29
+
30
+ [*Note 2*: To resolve symlinks, or perform other sanitization which
31
+ might require queries to secondary storage, such as hard disks, consider
32
+ `canonical` ([[fs.op.canonical]]). — *end note*]
33
+
34
+ [*Note 3*: Implementations are strongly encouraged to not query
35
+ secondary storage, and not consider `!exists(p)` an
36
+ error. — *end note*]
37
+
38
+ [*Example 1*: For POSIX-based operating systems, `absolute(p)` is
39
+ simply `current_path()/p`. For Windows-based operating systems,
40
+ `absolute` might have the same semantics as
41
+ `GetFullPathNameW`. — *end example*]
42
+
43
+ #### Canonical <a id="fs.op.canonical">[[fs.op.canonical]]</a>
44
+
45
+ ``` cpp
46
+ path canonical(const path& p, const path& base = current_path());
47
+ path canonical(const path& p, error_code& ec);
48
+ path canonical(const path& p, const path& base, error_code& ec);
49
+ ```
50
+
51
+ *Effects:* Converts `p`, which must exist, to an absolute path that has
52
+ no symbolic link, *dot*, or *dot-dot* elements in its pathname in the
53
+ generic format.
54
+
55
+ *Returns:* A path that refers to the same file system object as
56
+ `absolute(p, base)`. For the overload without a `base` argument, `base`
57
+ is `current_path()`. Signatures with argument `ec` return `path()` if an
58
+ error occurs.
59
+
60
+ *Throws:* As specified in  [[fs.err.report]].
61
+
62
+ *Remarks:* `!exists(p)` is an error.
63
+
64
+ #### Copy <a id="fs.op.copy">[[fs.op.copy]]</a>
65
+
66
+ ``` cpp
67
+ void copy(const path& from, const path& to);
68
+ ```
69
+
70
+ *Effects:* Equivalent to `copy(from, to, copy_options::none)`.
71
+
72
+ ``` cpp
73
+ void copy(const path& from, const path& to, error_code& ec) noexcept;
74
+ ```
75
+
76
+ *Effects:* Equivalent to `copy(from, to, copy_options::none, ec)`.
77
+
78
+ ``` cpp
79
+ void copy(const path& from, const path& to, copy_options options);
80
+ void copy(const path& from, const path& to, copy_options options,
81
+ error_code& ec) noexcept;
82
+ ```
83
+
84
+ *Requires:* At most one element from each option group
85
+ ([[fs.enum.copy.opts]]) is set in `options`.
86
+
87
+ *Effects:* Before the first use of `f` and `t`:
88
+
89
+ - If
90
+ ``` cpp
91
+ (options & copy_options::create_symlinks) != copy_options::none ||
92
+ (options & copy_options::skip_symlinks) != copy_options::none
93
+ ```
94
+
95
+ then `auto f = symlink_status(from)` and if needed
96
+ `auto t = symlink_status(to)`.
97
+ - Otherwise, if
98
+ ``` cpp
99
+ (options & copy_options::copy_symlinks) != copy_options::none
100
+ ```
101
+
102
+ then `auto f = symlink_status(from)` and if needed
103
+ `auto t = status(to)`.
104
+ - Otherwise, `auto f = status(from)` and if needed
105
+ `auto t = status(to)`.
106
+
107
+ Effects are then as follows:
108
+
109
+ - If `f.type()` or `t.type()` is an implementation-defined file
110
+ type ([[fs.enum.file_type]]), then the effects are
111
+ *implementation-defined*.
112
+ - Otherwise, an error is reported as specified in  [[fs.err.report]] if:
113
+ - `!exists(f)`, or
114
+ - `equivalent(from, to)`, or
115
+ - `is_other(f) || is_other(t)`, or
116
+ - `is_directory(f) && is_regular_file(t)`.
117
+ - Otherwise, if `is_symlink(f)`, then:
118
+ - If `(options & copy_options::skip_symlinks) != copy_options::none`
119
+ then return.
120
+ - Otherwise if
121
+ ``` cpp
122
+ !exists(t) && (options & copy_options::copy_symlinks) != copy_options::none
123
+ ```
124
+
125
+ then `copy_symlink(from, to)`.
126
+ - Otherwise report an error as specified in  [[fs.err.report]].
127
+ - Otherwise, if `is_regular_file(f)`, then:
128
+ - If
129
+ `(options & copy_options::directories_only) != copy_options::none`,
130
+ then return.
131
+ - Otherwise, if
132
+ `(options & copy_options::create_symlinks) `` != copy_options::none`,
133
+ then create a symbolic link to the source file.
134
+ - Otherwise, if
135
+ `(options & copy_options::create_hard_links) != copy_options::none`,
136
+ then create a hard link to the source file.
137
+ - Otherwise, if `is_directory(t)`, then
138
+ `copy_file(from, to/from.filename(), options)`.
139
+ - Otherwise, `copy_file(from, to, options)`.
140
+ - Otherwise, if
141
+ ``` cpp
142
+ is_directory(f) &&
143
+ ((options & copy_options::recursive) != copy_options::none ||
144
+ options == copy_options::none)
145
+ ```
146
+
147
+ then:
148
+ - If `!exists(t)`, then `create_directory(to, from)`.
149
+ - Then, iterate over the files in `from`, as if by
150
+ ``` cpp
151
+ for (const directory_entry& x : directory_iterator(from))
152
+ copy(x.path(), to/x.path().filename(), options | copy_options::unspecified)
153
+ ```
154
+ - Otherwise, for the signature with argument `ec`, `ec.clear()`.
155
+ - Otherwise, no effects.
156
+
157
+ *Throws:* As specified in  [[fs.err.report]].
158
+
159
+ *Remarks:* For the signature with argument `ec`, any library functions
160
+ called by the implementation shall have an `error_code` argument if
161
+ applicable.
162
+
163
+ [*Example 1*:
164
+
165
+ Given this directory structure:
166
+
167
+ ``` cpp
168
+ /dir1
169
+ file1
170
+ file2
171
+ dir2
172
+ file3
173
+ ```
174
+
175
+ Calling `copy("/dir1", "/dir3")` would result in:
176
+
177
+ ``` cpp
178
+ /dir1
179
+ file1
180
+ file2
181
+ dir2
182
+ file3
183
+ /dir3
184
+ file1
185
+ file2
186
+ ```
187
+
188
+ Alternatively, calling `copy("/dir1", "/dir3", copy_options::recursive)`
189
+ would result in:
190
+
191
+ ``` cpp
192
+ /dir1
193
+ file1
194
+ file2
195
+ dir2
196
+ file3
197
+ /dir3
198
+ file1
199
+ file2
200
+ dir2
201
+ file3
202
+ ```
203
+
204
+ — *end example*]
205
+
206
+ #### Copy file <a id="fs.op.copy_file">[[fs.op.copy_file]]</a>
207
+
208
+ ``` cpp
209
+ bool copy_file(const path& from, const path& to);
210
+ bool copy_file(const path& from, const path& to, error_code& ec) noexcept;
211
+ ```
212
+
213
+ *Returns:* `copy_file(from, to, copy_options::none)` or
214
+ `copy_file(from, to, copy_options::none, ec)`, respectively.
215
+
216
+ *Throws:* As specified in  [[fs.err.report]].
217
+
218
+ ``` cpp
219
+ bool copy_file(const path& from, const path& to, copy_options options);
220
+ bool copy_file(const path& from, const path& to, copy_options options,
221
+ error_code& ec) noexcept;
222
+ ```
223
+
224
+ *Requires:* At most one element from each option group
225
+ ([[fs.enum.copy.opts]]) is set in `options`.
226
+
227
+ *Effects:* As follows:
228
+
229
+ - Report a file already exists error as specified in  [[fs.err.report]]
230
+ if:
231
+ - `!is_regular_file(from)`, or
232
+ - `exists(to)` and `!is_regular_file(to)`, or
233
+ - `exists(to)` and `equivalent(from, to)`, or
234
+ - `exists(to)` and
235
+ ``` cpp
236
+ (options & (copy_options::skip_existing |
237
+ copy_options::overwrite_existing |
238
+ copy_options::update_existing)) == copy_options::none
239
+ ```
240
+ - Otherwise, copy the contents and attributes of the file `from`
241
+ resolves to, to the file `to` resolves to, if:
242
+ - `!exists(to)`, or
243
+ - `(options & copy_options::overwrite_existing) != copy_options::none`,
244
+ or
245
+ - `(options & copy_options::update_existing) `` `` != copy_options::none`
246
+ and `from` is more recent than `to`, determined as if by use of the
247
+ `last_write_time` function ([[fs.op.last_write_time]]).
248
+ - Otherwise, no effects.
249
+
250
+ *Returns:* `true` if the `from` file was copied, otherwise `false`. The
251
+ signature with argument `ec` returns `false` if an error occurs.
252
+
253
+ *Throws:* As specified in  [[fs.err.report]].
254
+
255
+ *Complexity:* At most one direct or indirect invocation of `status(to)`.
256
+
257
+ #### Copy symlink <a id="fs.op.copy_symlink">[[fs.op.copy_symlink]]</a>
258
+
259
+ ``` cpp
260
+ void copy_symlink(const path& existing_symlink, const path& new_symlink);
261
+ void copy_symlink(const path& existing_symlink, const path& new_symlink,
262
+ error_code& ec) noexcept;
263
+ ```
264
+
265
+ *Effects:* Equivalent to
266
+ *`function`*`(read_symlink(existing_symlink), new_symlink)` or
267
+ *`function`*`(read_symlink(existing_symlink, ec), new_symlink, ec)`,
268
+ respectively, where in each case *`function`* is `create_symlink` or
269
+ `create_directory_symlink` as appropriate.
270
+
271
+ *Throws:* As specified in  [[fs.err.report]].
272
+
273
+ #### Create directories <a id="fs.op.create_directories">[[fs.op.create_directories]]</a>
274
+
275
+ ``` cpp
276
+ bool create_directories(const path& p);
277
+ bool create_directories(const path& p, error_code& ec) noexcept;
278
+ ```
279
+
280
+ *Effects:* Establishes the postcondition by calling `create_directory()`
281
+ for any element of `p` that does not exist.
282
+
283
+ *Postconditions:* `is_directory(p)`.
284
+
285
+ *Returns:* `true` if a new directory was created, otherwise `false`. The
286
+ signature with argument `ec` returns `false` if an error occurs.
287
+
288
+ *Throws:* As specified in  [[fs.err.report]].
289
+
290
+ *Complexity:* 𝑂(n) where *n* is the number of elements of `p` that do
291
+ not exist.
292
+
293
+ #### Create directory <a id="fs.op.create_directory">[[fs.op.create_directory]]</a>
294
+
295
+ ``` cpp
296
+ bool create_directory(const path& p);
297
+ bool create_directory(const path& p, error_code& ec) noexcept;
298
+ ```
299
+
300
+ *Effects:* Establishes the postcondition by attempting to create the
301
+ directory `p` resolves to, as if by POSIX `mkdir()` with a second
302
+ argument of `static_cast<int>(perms::all)`. Creation failure because `p`
303
+ resolves to an existing directory shall not be treated as an error.
304
+
305
+ *Postconditions:* `is_directory(p)`.
306
+
307
+ *Returns:* `true` if a new directory was created, otherwise `false`. The
308
+ signature with argument `ec` returns `false` if an error occurs.
309
+
310
+ *Throws:* As specified in  [[fs.err.report]].
311
+
312
+ ``` cpp
313
+ bool create_directory(const path& p, const path& existing_p);
314
+ bool create_directory(const path& p, const path& existing_p, error_code& ec) noexcept;
315
+ ```
316
+
317
+ *Effects:* Establishes the postcondition by attempting to create the
318
+ directory `p` resolves to, with attributes copied from directory
319
+ `existing_p`. The set of attributes copied is operating system
320
+ dependent. Creation failure because `p` resolves to an existing
321
+ directory shall not be treated as an error.
322
+
323
+ [*Note 1*: For POSIX-based operating systems, the attributes are those
324
+ copied by native API `stat(existing_p.c_str(), &attributes_stat)`
325
+ followed by `mkdir(p.c_str(), attributes_stat.st_mode)`. For
326
+ Windows-based operating systems, the attributes are those copied by
327
+ native API
328
+ `CreateDirectoryExW(existing_p.c_str(), p.c_str(), 0)`. — *end note*]
329
+
330
+ *Postconditions:* `is_directory(p)`.
331
+
332
+ *Returns:* `true` if a new directory was created, otherwise `false`. The
333
+ signature with argument `ec` returns `false` if an error occurs.
334
+
335
+ *Throws:* As specified in  [[fs.err.report]].
336
+
337
+ #### Create directory symlink <a id="fs.op.create_dir_symlk">[[fs.op.create_dir_symlk]]</a>
338
+
339
+ ``` cpp
340
+ void create_directory_symlink(const path& to, const path& new_symlink);
341
+ void create_directory_symlink(const path& to, const path& new_symlink,
342
+ error_code& ec) noexcept;
343
+ ```
344
+
345
+ *Effects:* Establishes the postcondition, as if by POSIX `symlink()`.
346
+
347
+ *Postconditions:* `new_symlink` resolves to a symbolic link file that
348
+ contains an unspecified representation of `to`.
349
+
350
+ *Throws:* As specified in  [[fs.err.report]].
351
+
352
+ [*Note 1*: Some operating systems require symlink creation to identify
353
+ that the link is to a directory. Portable code should use
354
+ `create_directory_symlink()` to create directory symlinks rather than
355
+ `create_symlink()` — *end note*]
356
+
357
+ [*Note 2*: Some operating systems do not support symbolic links at all
358
+ or support them only for regular files. Some file systems (such as the
359
+ FAT file system) do not support symbolic links regardless of the
360
+ operating system. — *end note*]
361
+
362
+ #### Create hard link <a id="fs.op.create_hard_lk">[[fs.op.create_hard_lk]]</a>
363
+
364
+ ``` cpp
365
+ void create_hard_link(const path& to, const path& new_hard_link);
366
+ void create_hard_link(const path& to, const path& new_hard_link,
367
+ error_code& ec) noexcept;
368
+ ```
369
+
370
+ *Effects:* Establishes the postcondition, as if by POSIX `link()`.
371
+
372
+ *Postconditions:*
373
+
374
+ - `exists(to) && exists(new_hard_link) && equivalent(to, new_hard_link)`
375
+ - The contents of the file or directory `to` resolves to are unchanged.
376
+
377
+ *Throws:* As specified in  [[fs.err.report]].
378
+
379
+ [*Note 1*: Some operating systems do not support hard links at all or
380
+ support them only for regular files. Some file systems (such as the FAT
381
+ file system) do not support hard links regardless of the operating
382
+ system. Some file systems limit the number of links per
383
+ file. — *end note*]
384
+
385
+ #### Create symlink <a id="fs.op.create_symlink">[[fs.op.create_symlink]]</a>
386
+
387
+ ``` cpp
388
+ void create_symlink(const path& to, const path& new_symlink);
389
+ void create_symlink(const path& to, const path& new_symlink,
390
+ error_code& ec) noexcept;
391
+ ```
392
+
393
+ *Effects:* Establishes the postcondition, as if by POSIX `symlink()`.
394
+
395
+ *Postconditions:* `new_symlink` resolves to a symbolic link file that
396
+ contains an unspecified representation of `to`.
397
+
398
+ *Throws:* As specified in  [[fs.err.report]].
399
+
400
+ [*Note 1*: Some operating systems do not support symbolic links at all
401
+ or support them only for regular files. Some file systems (such as the
402
+ FAT file system) do not support symbolic links regardless of the
403
+ operating system. — *end note*]
404
+
405
+ #### Current path <a id="fs.op.current_path">[[fs.op.current_path]]</a>
406
+
407
+ ``` cpp
408
+ path current_path();
409
+ path current_path(error_code& ec);
410
+ ```
411
+
412
+ *Returns:* The absolute path of the current working directory, whose
413
+ pathname in the native format is obtained as if by POSIX `getcwd()`. The
414
+ signature with argument `ec` returns `path()` if an error occurs.
415
+
416
+ *Throws:* As specified in  [[fs.err.report]].
417
+
418
+ *Remarks:* The current working directory is the directory, associated
419
+ with the process, that is used as the starting location in pathname
420
+ resolution for relative paths.
421
+
422
+ [*Note 1*: The `current_path()` name was chosen to emphasize that the
423
+ returned value is a path, not just a single directory
424
+ name. — *end note*]
425
+
426
+ [*Note 2*: The current path as returned by many operating systems is a
427
+ dangerous global variable. It may be changed unexpectedly by a
428
+ third-party or system library functions, or by another
429
+ thread. — *end note*]
430
+
431
+ ``` cpp
432
+ void current_path(const path& p);
433
+ void current_path(const path& p, error_code& ec) noexcept;
434
+ ```
435
+
436
+ *Effects:* Establishes the postcondition, as if by POSIX `chdir()`.
437
+
438
+ *Postconditions:* `equivalent(p, current_path())`.
439
+
440
+ *Throws:* As specified in  [[fs.err.report]].
441
+
442
+ [*Note 3*: The current path for many operating systems is a dangerous
443
+ global state. It may be changed unexpectedly by a third-party or system
444
+ library functions, or by another thread. — *end note*]
445
+
446
+ #### Equivalent <a id="fs.op.equivalent">[[fs.op.equivalent]]</a>
447
+
448
+ ``` cpp
449
+ bool equivalent(const path& p1, const path& p2);
450
+ bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
451
+ ```
452
+
453
+ Let `s1` and `s2` be `file_status`s, determined as if by `status(p1)`
454
+ and `status(p2)`, respectively.
455
+
456
+ *Effects:* Determines `s1` and `s2`. If
457
+ `(!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))` an
458
+ error is reported ([[fs.err.report]]).
459
+
460
+ *Returns:* `true`, if `s1 == s2` and `p1` and `p2` resolve to the same
461
+ file system entity, else `false`. The signature with argument `ec`
462
+ returns `false` if an error occurs.
463
+
464
+ Two paths are considered to resolve to the same file system entity if
465
+ two candidate entities reside on the same device at the same location.
466
+ This is determined as if by the values of the POSIX `stat` structure,
467
+ obtained as if by `stat()` for the two paths, having equal `st_dev`
468
+ values and equal `st_ino` values.
469
+
470
+ *Throws:* As specified in  [[fs.err.report]].
471
+
472
+ #### Exists <a id="fs.op.exists">[[fs.op.exists]]</a>
473
+
474
+ ``` cpp
475
+ bool exists(file_status s) noexcept;
476
+ ```
477
+
478
+ *Returns:* `status_known(s) && s.type() != file_type::not_found`.
479
+
480
+ ``` cpp
481
+ bool exists(const path& p);
482
+ bool exists(const path& p, error_code& ec) noexcept;
483
+ ```
484
+
485
+ Let `s` be a `file_status`, determined as if by `status(p)` or
486
+ `status(p, ec)`, respectively.
487
+
488
+ *Effects:* The signature with argument `ec` calls `ec.clear()` if
489
+ `status_known(s)`.
490
+
491
+ *Returns:* `exists(s)`.
492
+
493
+ *Throws:* As specified in  [[fs.err.report]].
494
+
495
+ #### File size <a id="fs.op.file_size">[[fs.op.file_size]]</a>
496
+
497
+ ``` cpp
498
+ uintmax_t file_size(const path& p);
499
+ uintmax_t file_size(const path& p, error_code& ec) noexcept;
500
+ ```
501
+
502
+ *Returns:*
503
+
504
+ - If `!exists(p)` an error is reported ([[fs.err.report]]).
505
+ - Otherwise, if `is_regular_file(p)`, the size in bytes of the file `p`
506
+ resolves to, determined as if by the value of the POSIX `stat`
507
+ structure member `st_size` obtained as if by POSIX `stat()`.
508
+ - Otherwise, the result is *implementation-defined*.
509
+
510
+ The signature with argument `ec` returns `static_cast<uintmax_t>(-1)` if
511
+ an error occurs.
512
+
513
+ *Throws:* As specified in  [[fs.err.report]].
514
+
515
+ #### Hard link count <a id="fs.op.hard_lk_ct">[[fs.op.hard_lk_ct]]</a>
516
+
517
+ ``` cpp
518
+ uintmax_t hard_link_count(const path& p);
519
+ uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
520
+ ```
521
+
522
+ *Returns:* The number of hard links for `p`. The signature with argument
523
+ `ec` returns `static_cast<uintmax_t>(-1)` if an error occurs.
524
+
525
+ *Throws:* As specified in  [[fs.err.report]].
526
+
527
+ #### Is block file <a id="fs.op.is_block_file">[[fs.op.is_block_file]]</a>
528
+
529
+ ``` cpp
530
+ bool is_block_file(file_status s) noexcept;
531
+ ```
532
+
533
+ *Returns:* `s.type() == file_type::block`.
534
+
535
+ ``` cpp
536
+ bool is_block_file(const path& p);
537
+ bool is_block_file(const path& p, error_code& ec) noexcept;
538
+ ```
539
+
540
+ *Returns:* `is_block_file(status(p))` or `is_block_file(status(p, ec))`,
541
+ respectively. The signature with argument `ec` returns `false` if an
542
+ error occurs.
543
+
544
+ *Throws:* As specified in  [[fs.err.report]].
545
+
546
+ #### Is character file <a id="fs.op.is_char_file">[[fs.op.is_char_file]]</a>
547
+
548
+ ``` cpp
549
+ bool is_character_file(file_status s) noexcept;
550
+ ```
551
+
552
+ *Returns:* `s.type() == file_type::character`.
553
+
554
+ ``` cpp
555
+ bool is_character_file(const path& p);
556
+ bool is_character_file(const path& p, error_code& ec) noexcept;
557
+ ```
558
+
559
+ *Returns:* `is_character_file(status(p))` or
560
+ `is_character_file(status(p, ec))`, respectively.
561
+ The signature with argument `ec` returns `false` if an error occurs.
562
+
563
+ *Throws:* As specified in  [[fs.err.report]].
564
+
565
+ #### Is directory <a id="fs.op.is_directory">[[fs.op.is_directory]]</a>
566
+
567
+ ``` cpp
568
+ bool is_directory(file_status s) noexcept;
569
+ ```
570
+
571
+ *Returns:* `s.type() == file_type::directory`.
572
+
573
+ ``` cpp
574
+ bool is_directory(const path& p);
575
+ bool is_directory(const path& p, error_code& ec) noexcept;
576
+ ```
577
+
578
+ *Returns:* `is_directory(status(p))` or `is_directory(status(p, ec))`,
579
+ respectively. The signature with argument `ec` returns `false` if an
580
+ error occurs.
581
+
582
+ *Throws:* As specified in  [[fs.err.report]].
583
+
584
+ #### Is empty <a id="fs.op.is_empty">[[fs.op.is_empty]]</a>
585
+
586
+ ``` cpp
587
+ bool is_empty(const path& p);
588
+ bool is_empty(const path& p, error_code& ec) noexcept;
589
+ ```
590
+
591
+ *Effects:*
592
+
593
+ - Determine `file_status s`, as if by `status(p)` or `status(p, ec)`,
594
+ respectively.
595
+ - For the signature with argument `ec`, return `false` if an error
596
+ occurred.
597
+ - Otherwise, if `is_directory(s)`:
598
+ - Create a variable `itr`, as if by `directory_iterator itr(p)` or
599
+ `directory_iterator itr(p, ec)`, respectively.
600
+ - For the signature with argument `ec`, return `false` if an error
601
+ occurred.
602
+ - Otherwise, return `itr == directory_iterator()`.
603
+ - Otherwise:
604
+ - Determine `uintmax_t sz`, as if by `file_size(p)` or
605
+ `file_size(p, ec)`, respectively.
606
+ - For the signature with argument `ec`, return `false` if an error
607
+ occurred.
608
+ - Otherwise, return `sz == 0`.
609
+
610
+ *Throws:* As specified in  [[fs.err.report]].
611
+
612
+ #### Is fifo <a id="fs.op.is_fifo">[[fs.op.is_fifo]]</a>
613
+
614
+ ``` cpp
615
+ bool is_fifo(file_status s) noexcept;
616
+ ```
617
+
618
+ *Returns:* `s.type() == file_type::fifo`.
619
+
620
+ ``` cpp
621
+ bool is_fifo(const path& p);
622
+ bool is_fifo(const path& p, error_code& ec) noexcept;
623
+ ```
624
+
625
+ *Returns:* `is_fifo(status(p))` or `is_fifo(status(p, ec))`,
626
+ respectively. The signature with argument `ec` returns `false` if an
627
+ error occurs.
628
+
629
+ *Throws:* As specified in  [[fs.err.report]].
630
+
631
+ #### Is other <a id="fs.op.is_other">[[fs.op.is_other]]</a>
632
+
633
+ ``` cpp
634
+ bool is_other(file_status s) noexcept;
635
+ ```
636
+
637
+ *Returns:*
638
+ `exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s)`.
639
+
640
+ ``` cpp
641
+ bool is_other(const path& p);
642
+ bool is_other(const path& p, error_code& ec) noexcept;
643
+ ```
644
+
645
+ *Returns:* `is_other(status(p))` or `is_other(status(p, ec))`,
646
+ respectively. The signature with argument `ec` returns `false` if an
647
+ error occurs.
648
+
649
+ *Throws:* As specified in  [[fs.err.report]].
650
+
651
+ #### Is regular file <a id="fs.op.is_regular_file">[[fs.op.is_regular_file]]</a>
652
+
653
+ ``` cpp
654
+ bool is_regular_file(file_status s) noexcept;
655
+ ```
656
+
657
+ *Returns:* `s.type() == file_type::regular`.
658
+
659
+ ``` cpp
660
+ bool is_regular_file(const path& p);
661
+ ```
662
+
663
+ *Returns:* `is_regular_file(status(p))`.
664
+
665
+ *Throws:* `filesystem_error` if `status(p)` would throw
666
+ `filesystem_error.`
667
+
668
+ ``` cpp
669
+ bool is_regular_file(const path& p, error_code& ec) noexcept;
670
+ ```
671
+
672
+ *Effects:* Sets `ec` as if by `status(p, ec)`.
673
+
674
+ [*Note 1*: `file_type::none`, `file_type::not_found` and
675
+ `file_type::unknown` cases set `ec` to error values. To distinguish
676
+ between cases, call the `status` function directly. — *end note*]
677
+
678
+ *Returns:* `is_regular_file(status(p, ec))`. Returns `false` if an error
679
+ occurs.
680
+
681
+ #### Is socket <a id="fs.op.is_socket">[[fs.op.is_socket]]</a>
682
+
683
+ ``` cpp
684
+ bool is_socket(file_status s) noexcept;
685
+ ```
686
+
687
+ *Returns:* `s.type() == file_type::socket`.
688
+
689
+ ``` cpp
690
+ bool is_socket(const path& p);
691
+ bool is_socket(const path& p, error_code& ec) noexcept;
692
+ ```
693
+
694
+ *Returns:* `is_socket(status(p))` or `is_socket(status(p, ec))`,
695
+ respectively. The signature with argument `ec` returns `false` if an
696
+ error occurs.
697
+
698
+ *Throws:* As specified in  [[fs.err.report]].
699
+
700
+ #### Is symlink <a id="fs.op.is_symlink">[[fs.op.is_symlink]]</a>
701
+
702
+ ``` cpp
703
+ bool is_symlink(file_status s) noexcept;
704
+ ```
705
+
706
+ *Returns:* `s.type() == file_type::symlink`.
707
+
708
+ ``` cpp
709
+ bool is_symlink(const path& p);
710
+ bool is_symlink(const path& p, error_code& ec) noexcept;
711
+ ```
712
+
713
+ *Returns:* `is_symlink(symlink_status(p))` or
714
+ `is_symlink(symlink_status(p, ec))`, respectively. The signature with
715
+ argument `ec` returns `false` if an error occurs.
716
+
717
+ *Throws:* As specified in  [[fs.err.report]].
718
+
719
+ #### Last write time <a id="fs.op.last_write_time">[[fs.op.last_write_time]]</a>
720
+
721
+ ``` cpp
722
+ file_time_type last_write_time(const path& p);
723
+ file_time_type last_write_time(const path& p, error_code& ec) noexcept;
724
+ ```
725
+
726
+ *Returns:* The time of last data modification of `p`, determined as if
727
+ by the value of the POSIX `stat` structure member `st_mtime` obtained as
728
+ if by POSIX `stat()`. The signature with argument `ec` returns
729
+ `file_time_type::min()` if an error occurs.
730
+
731
+ *Throws:* As specified in  [[fs.err.report]].
732
+
733
+ ``` cpp
734
+ void last_write_time(const path& p, file_time_type new_time);
735
+ void last_write_time(const path& p, file_time_type new_time,
736
+ error_code& ec) noexcept;
737
+ ```
738
+
739
+ *Effects:* Sets the time of last data modification of the file resolved
740
+ to by `p` to `new_time`, as if by POSIX `futimens()`.
741
+
742
+ *Throws:* As specified in  [[fs.err.report]].
743
+
744
+ [*Note 1*: A postcondition of `last_write_time(p) == new_time` is not
745
+ specified since it might not hold for file systems with coarse time
746
+ granularity. — *end note*]
747
+
748
+ #### Permissions <a id="fs.op.permissions">[[fs.op.permissions]]</a>
749
+
750
+ ``` cpp
751
+ void permissions(const path& p, perms prms, perm_options opts=perm_options::replace);
752
+ void permissions(const path& p, perms prms, error_code& ec) noexcept;
753
+ void permissions(const path& p, perms prms, perm_options opts, error_code& ec);
754
+ ```
755
+
756
+ *Requires:* Exactly one of the `perm_options` constants `replace`,
757
+ `add`, or `remove` is present in `opts`.
758
+
759
+ *Remarks:* The second signature behaves as if it had an additional
760
+ parameter `perm_options` `opts` with an argument of
761
+ `perm_options::replace`.
762
+
763
+ *Effects:* Applies the action specified by `opts` to the file `p`
764
+ resolves to, or to file `p` itself if `p` is a symbolic link and
765
+ `perm_options::nofollow` is set in `opts`. The action is applied as if
766
+ by POSIX `fchmodat()`.
767
+
768
+ [*Note 1*: Conceptually permissions are viewed as bits, but the actual
769
+ implementation may use some other mechanism. — *end note*]
770
+
771
+ *Throws:* As specified in  [[fs.err.report]].
772
+
773
+ #### Proximate <a id="fs.op.proximate">[[fs.op.proximate]]</a>
774
+
775
+ ``` cpp
776
+ path proximate(const path& p, error_code& ec);
777
+ ```
778
+
779
+ *Returns:* `proximate(p, current_path(), ec)`.
780
+
781
+ *Throws:* As specified in  [[fs.err.report]].
782
+
783
+ ``` cpp
784
+ path proximate(const path& p, const path& base = current_path());
785
+ path proximate(const path& p, const path& base, error_code& ec);
786
+ ```
787
+
788
+ *Returns:* For the first form:
789
+
790
+ ``` cpp
791
+ weakly_canonical(p).lexically_proximate(weakly_canonical(base));
792
+ ```
793
+
794
+ For the second form:
795
+
796
+ ``` cpp
797
+ weakly_canonical(p, ec).lexically_proximate(weakly_canonical(base, ec));
798
+ ```
799
+
800
+ or `path()` at the first error occurrence, if any.
801
+
802
+ *Throws:* As specified in  [[fs.err.report]].
803
+
804
+ #### Read symlink <a id="fs.op.read_symlink">[[fs.op.read_symlink]]</a>
805
+
806
+ ``` cpp
807
+ path read_symlink(const path& p);
808
+ path read_symlink(const path& p, error_code& ec);
809
+ ```
810
+
811
+ *Returns:* If `p` resolves to a symbolic link, a `path` object
812
+ containing the contents of that symbolic link. The signature with
813
+ argument `ec` returns `path()` if an error occurs.
814
+
815
+ *Throws:* As specified in  [[fs.err.report]].
816
+
817
+ [*Note 1*: It is an error if `p` does not resolve to a symbolic
818
+ link. — *end note*]
819
+
820
+ #### Relative <a id="fs.op.relative">[[fs.op.relative]]</a>
821
+
822
+ ``` cpp
823
+ path relative(const path& p, error_code& ec);
824
+ ```
825
+
826
+ *Returns:* `relative(p, current_path(), ec)`.
827
+
828
+ *Throws:* As specified in  [[fs.err.report]].
829
+
830
+ ``` cpp
831
+ path relative(const path& p, const path& base = current_path());
832
+ path relative(const path& p, const path& base, error_code& ec);
833
+ ```
834
+
835
+ *Returns:* For the first form:
836
+
837
+ ``` cpp
838
+ weakly_canonical(p).lexically_relative(weakly_canonical(base));
839
+ ```
840
+
841
+ For the second form:
842
+
843
+ ``` cpp
844
+ weakly_canonical(p, ec).lexically_relative(weakly_canonical(base, ec));
845
+ ```
846
+
847
+ or `path()` at the first error occurrence, if any.
848
+
849
+ *Throws:* As specified in  [[fs.err.report]].
850
+
851
+ #### Remove <a id="fs.op.remove">[[fs.op.remove]]</a>
852
+
853
+ ``` cpp
854
+ bool remove(const path& p);
855
+ bool remove(const path& p, error_code& ec) noexcept;
856
+ ```
857
+
858
+ *Effects:* If `exists(symlink_status(p, ec))`, the file `p` is removed
859
+ as if by POSIX `remove()`.
860
+
861
+ [*Note 1*: A symbolic link is itself removed, rather than the file it
862
+ resolves to. — *end note*]
863
+
864
+ *Postconditions:* `!exists(symlink_status(p))`.
865
+
866
+ *Returns:* `false` if `p` did not exist, otherwise `true`. The signature
867
+ with argument `ec` returns `false` if an error occurs.
868
+
869
+ *Throws:* As specified in  [[fs.err.report]].
870
+
871
+ #### Remove all <a id="fs.op.remove_all">[[fs.op.remove_all]]</a>
872
+
873
+ ``` cpp
874
+ uintmax_t remove_all(const path& p);
875
+ uintmax_t remove_all(const path& p, error_code& ec) noexcept;
876
+ ```
877
+
878
+ *Effects:* Recursively deletes the contents of `p` if it exists, then
879
+ deletes file `p` itself, as if by POSIX `remove()`.
880
+
881
+ [*Note 1*: A symbolic link is itself removed, rather than the file it
882
+ resolves to. — *end note*]
883
+
884
+ *Postconditions:* `!exists(symlink_status(p))`.
885
+
886
+ *Returns:* The number of files removed. The signature with argument `ec`
887
+ returns `static_cast< uintmax_t>(-1)` if an error occurs.
888
+
889
+ *Throws:* As specified in  [[fs.err.report]].
890
+
891
+ #### Rename <a id="fs.op.rename">[[fs.op.rename]]</a>
892
+
893
+ ``` cpp
894
+ void rename(const path& old_p, const path& new_p);
895
+ void rename(const path& old_p, const path& new_p, error_code& ec) noexcept;
896
+ ```
897
+
898
+ *Effects:* Renames `old_p` to `new_p`, as if by POSIX `rename()`.
899
+
900
+ [*Note 1*:
901
+
902
+ - If `old_p` and `new_p` resolve to the same existing file, no action is
903
+ taken.
904
+ - Otherwise, the rename may include the following effects:
905
+ - if `new_p` resolves to an existing non-directory file, `new_p` is
906
+ removed; otherwise,
907
+ - if `new_p` resolves to an existing directory, `new_p` is removed if
908
+ empty on POSIX compliant operating systems but may be an error on
909
+ other operating systems.
910
+
911
+ A symbolic link is itself renamed, rather than the file it resolves to.
912
+
913
+ — *end note*]
914
+
915
+ *Throws:* As specified in  [[fs.err.report]].
916
+
917
+ #### Resize file <a id="fs.op.resize_file">[[fs.op.resize_file]]</a>
918
+
919
+ ``` cpp
920
+ void resize_file(const path& p, uintmax_t new_size);
921
+ void resize_file(const path& p, uintmax_t new_size, error_code& ec) noexcept;
922
+ ```
923
+
924
+ *Postconditions:* `file_size(p) == new_size`.
925
+
926
+ *Throws:* As specified in  [[fs.err.report]].
927
+
928
+ *Remarks:* Achieves its postconditions as if by POSIX `truncate()`.
929
+
930
+ #### Space <a id="fs.op.space">[[fs.op.space]]</a>
931
+
932
+ ``` cpp
933
+ space_info space(const path& p);
934
+ space_info space(const path& p, error_code& ec) noexcept;
935
+ ```
936
+
937
+ *Returns:* An object of type `space_info`. The value of the `space_info`
938
+ object is determined as if by using POSIX `statvfs` to obtain a POSIX
939
+ `struct statvfs`, and then multiplying its `f_blocks`, `f_bfree`, and
940
+ `f_bavail` members by its `f_frsize` member, and assigning the results
941
+ to the `capacity`, `free`, and `available` members respectively. Any
942
+ members for which the value cannot be determined shall be set to
943
+ `static_cast<uintmax_t>(-1)`. For the signature with argument `ec`, all
944
+ members are set to `static_cast<uintmax_t>(-1)` if an error occurs.
945
+
946
+ *Throws:* As specified in  [[fs.err.report]].
947
+
948
+ *Remarks:* The value of member `space_info::available` is operating
949
+ system dependent.
950
+
951
+ [*Note 1*: `available` may be less than `free`. — *end note*]
952
+
953
+ #### Status <a id="fs.op.status">[[fs.op.status]]</a>
954
+
955
+ ``` cpp
956
+ file_status status(const path& p);
957
+ ```
958
+
959
+ *Effects:* As if:
960
+
961
+ ``` cpp
962
+ error_code ec;
963
+ file_status result = status(p, ec);
964
+ if (result.type() == file_type::none)
965
+ throw filesystem_error(implementation-supplied-message, p, ec);
966
+ return result;
967
+ ```
968
+
969
+ *Returns:* See above.
970
+
971
+ *Throws:* `filesystem_error`.
972
+
973
+ [*Note 1*: `result` values of `file_status(file_type::not_found)` and
974
+ `file_status(file_type::unknown)` are not considered failures and do not
975
+ cause an exception to be thrown. — *end note*]
976
+
977
+ ``` cpp
978
+ file_status status(const path& p, error_code& ec) noexcept;
979
+ ```
980
+
981
+ *Effects:* If possible, determines the attributes of the file `p`
982
+ resolves to, as if by using POSIX `stat()` to obtain a POSIX
983
+ `struct stat`. If, during attribute determination, the underlying file
984
+ system API reports an error, sets `ec` to indicate the specific error
985
+ reported. Otherwise, `ec.clear()`.
986
+
987
+ [*Note 2*: This allows users to inspect the specifics of underlying API
988
+ errors even when the value returned by `status()` is not
989
+ `file_status(file_type::none)`. — *end note*]
990
+
991
+ Let `prms` denote the result of `(m & perms::mask)`, where `m` is
992
+ determined as if by converting the `st_mode` member of the obtained
993
+ `struct stat` to the type `perms`.
994
+
995
+ *Returns:*
996
+
997
+ - If `ec != error_code()`:
998
+ - If the specific error indicates that `p` cannot be resolved because
999
+ some element of the path does not exist, returns
1000
+ `file_status(file_type::not_found)`.
1001
+ - Otherwise, if the specific error indicates that `p` can be resolved
1002
+ but the attributes cannot be determined, returns
1003
+ `file_status(file_type::unknown)`.
1004
+ - Otherwise, returns `file_status(file_type::none)`.
1005
+
1006
+ \[*Note 1*: These semantics distinguish between `p` being known not to
1007
+ exist, `p` existing but not being able to determine its attributes,
1008
+ and there being an error that prevents even knowing if `p` exists.
1009
+ These distinctions are important to some use cases. — *end note*]
1010
+ - Otherwise,
1011
+ - If the attributes indicate a regular file, as if by POSIX `S_ISREG`,
1012
+ returns `file_status(file_type::regular, prms)`.
1013
+ \[*Note 2*: `file_type::regular` implies appropriate `<fstream>`
1014
+ operations would succeed, assuming no hardware, permission, access,
1015
+ or file system race errors. Lack of `file_type::regular` does not
1016
+ necessarily imply `<fstream>` operations would fail on a
1017
+ directory. — *end note*]
1018
+ - Otherwise, if the attributes indicate a directory, as if by POSIX
1019
+ `S_ISDIR`, returns `file_status(file_type::directory, prms)`.
1020
+ \[*Note 3*: `file_type::directory` implies that calling
1021
+ `directory_iterator(p)` would succeed. — *end note*]
1022
+ - Otherwise, if the attributes indicate a block special file, as if by
1023
+ POSIX `S_ISBLK`, returns `file_status(file_type::block, prms)`.
1024
+ - Otherwise, if the attributes indicate a character special file, as
1025
+ if by POSIX `S_ISCHR`, returns
1026
+ `file_status(file_type::character, prms)`.
1027
+ - Otherwise, if the attributes indicate a fifo or pipe file, as if by
1028
+ POSIX `S_ISFIFO`, returns `file_status(file_type::fifo, prms)`.
1029
+ - Otherwise, if the attributes indicate a socket, as if by POSIX
1030
+ `S_ISSOCK`, returns `file_status(file_type::socket, prms)`.
1031
+ - Otherwise, if the attributes indicate an implementation-defined file
1032
+ type ([[fs.enum.file_type]]), returns
1033
+ `file_status(file_type::`*`A`*`, prms)`, where *A* is the constant
1034
+ for the *implementation-defined* file type.
1035
+ - Otherwise, returns `file_status(file_type::unknown, prms)`.
1036
+
1037
+ *Remarks:* If a symbolic link is encountered during pathname resolution,
1038
+ pathname resolution continues using the contents of the symbolic link.
1039
+
1040
+ #### Status known <a id="fs.op.status_known">[[fs.op.status_known]]</a>
1041
+
1042
+ ``` cpp
1043
+ bool status_known(file_status s) noexcept;
1044
+ ```
1045
+
1046
+ *Returns:* `s.type() != file_type::none`.
1047
+
1048
+ #### Symlink status <a id="fs.op.symlink_status">[[fs.op.symlink_status]]</a>
1049
+
1050
+ ``` cpp
1051
+ file_status symlink_status(const path& p);
1052
+ file_status symlink_status(const path& p, error_code& ec) noexcept;
1053
+ ```
1054
+
1055
+ *Effects:* Same as `status()`, above, except that the attributes of `p`
1056
+ are determined as if by using POSIX `lstat()` to obtain a POSIX
1057
+ `struct stat`.
1058
+
1059
+ Let `prms` denote the result of `(m & perms::mask)`, where `m` is
1060
+ determined as if by converting the `st_mode` member of the obtained
1061
+ `struct stat` to the type `perms`.
1062
+
1063
+ *Returns:* Same as `status()`, above, except that if the attributes
1064
+ indicate a symbolic link, as if by POSIX `S_ISLNK`, returns
1065
+ `file_status(file_type::symlink, prms)`. The signature with argument
1066
+ `ec` returns `file_status(file_type::none)` if an error occurs.
1067
+
1068
+ *Remarks:* Pathname resolution terminates if `p` names a symbolic link.
1069
+
1070
+ *Throws:* As specified in  [[fs.err.report]].
1071
+
1072
+ #### Temporary directory path <a id="fs.op.temp_dir_path">[[fs.op.temp_dir_path]]</a>
1073
+
1074
+ ``` cpp
1075
+ path temp_directory_path();
1076
+ path temp_directory_path(error_code& ec);
1077
+ ```
1078
+
1079
+ *Returns:* An unspecifed directory path suitable for temporary files. An
1080
+ error shall be reported if `!exists(p) || !is_directory(p)`, where `p`
1081
+ is the path to be returned. The signature with argument `ec` returns
1082
+ `path()` if an error occurs.
1083
+
1084
+ *Throws:* As specified in  [[fs.err.report]].
1085
+
1086
+ [*Example 1*: For POSIX-based operating systems, an implementation
1087
+ might return the path supplied by the first environment variable found
1088
+ in the list TMPDIR, TMP, TEMP, TEMPDIR, or if none of these are found,
1089
+ `"/tmp"`. For Windows-based operating systems, an implementation might
1090
+ return the path reported by the Windows `GetTempPath` API
1091
+ function. — *end example*]
1092
+
1093
+ #### Weakly canonical <a id="fs.op.weakly_canonical">[[fs.op.weakly_canonical]]</a>
1094
+
1095
+ ``` cpp
1096
+ path weakly_canonical(const path& p);
1097
+ path weakly_canonical(const path& p, error_code& ec);
1098
+ ```
1099
+
1100
+ *Returns:* `p` with symlinks resolved and the result
1101
+ normalized ([[fs.def.normal.form]]).
1102
+
1103
+ *Effects:* Using `status(p)` or `status(p, ec)`, respectively, to
1104
+ determine existence, return a path composed by `operator/=` from the
1105
+ result of calling `canonical()` without a `base` argument and with a
1106
+ path argument composed of the leading elements of `p` that exist, if
1107
+ any, followed by the elements of `p` that do not exist, if any. For the
1108
+ first form, `canonical()` is called without an `error_code` argument.
1109
+ For the second form, `canonical()` is called with `ec` as an
1110
+ `error_code` argument, and `path()` is returned at the first error
1111
+ occurrence, if any.
1112
+
1113
+ *Postconditions:* The returned path is in normal
1114
+ form ([[fs.def.normal.form]]).
1115
+
1116
+ *Remarks:* Implementations are encouraged to avoid unnecessary
1117
+ normalization such as when `canonical` has already been called on the
1118
+ entirety of `p`.
1119
+
1120
+ *Throws:* As specified in  [[fs.err.report]].
1121
+