From Jason Turner

[fs.op.funcs]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8fq4fmwp/{from.md → to.md} +131 -132
tmp/tmp8fq4fmwp/{from.md → to.md} RENAMED
@@ -1,21 +1,23 @@
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.race.behavior]], 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
 
@@ -25,12 +27,12 @@ location as `p` according to the operating system [[fs.conform.os]].
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*]
@@ -41,12 +43,12 @@ simply `current_path()/p`. For Windows-based operating systems,
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);
47
- path canonical(const path& p, error_code& ec);
48
  ```
49
 
50
  *Effects:* Converts `p` to an absolute path that has no symbolic link,
51
  dot, or dot-dot elements in its pathname in the generic format.
52
 
@@ -59,24 +61,24 @@ error occurs.
59
  *Remarks:* `!exists(p)` is an error.
60
 
61
  #### Copy <a id="fs.op.copy">[[fs.op.copy]]</a>
62
 
63
  ``` cpp
64
- void copy(const path& from, const path& to);
65
  ```
66
 
67
  *Effects:* Equivalent to `copy(from, to, copy_options::none)`.
68
 
69
  ``` cpp
70
- void copy(const path& from, const path& to, error_code& ec);
71
  ```
72
 
73
  *Effects:* Equivalent to `copy(from, to, copy_options::none, ec)`.
74
 
75
  ``` cpp
76
- void copy(const path& from, const path& to, copy_options options);
77
- void copy(const path& from, const path& to, copy_options options,
78
  error_code& ec);
79
  ```
80
 
81
  *Preconditions:* At most one element from each option
82
  group [[fs.enum.copy.opts]] is set in `options`.
@@ -213,22 +215,22 @@ would result in:
213
  — *end example*]
214
 
215
  #### Copy file <a id="fs.op.copy.file">[[fs.op.copy.file]]</a>
216
 
217
  ``` cpp
218
- bool copy_file(const path& from, const path& to);
219
- bool copy_file(const path& from, const path& to, error_code& ec);
220
  ```
221
 
222
  *Returns:* `copy_file(from, to, copy_options::none)` or
223
  `copy_file(from, to, copy_options::none, ec)`, respectively.
224
 
225
  *Throws:* As specified in  [[fs.err.report]].
226
 
227
  ``` cpp
228
- bool copy_file(const path& from, const path& to, copy_options options);
229
- bool copy_file(const path& from, const path& to, copy_options options,
230
  error_code& ec);
231
  ```
232
 
233
  *Preconditions:* At most one element from each option
234
  group [[fs.enum.copy.opts]] is set in `options`.
@@ -263,12 +265,12 @@ signature with argument `ec` returns `false` if an error occurs.
263
  *Complexity:* At most one direct or indirect invocation of `status(to)`.
264
 
265
  #### Copy symlink <a id="fs.op.copy.symlink">[[fs.op.copy.symlink]]</a>
266
 
267
  ``` cpp
268
- void copy_symlink(const path& existing_symlink, const path& new_symlink);
269
- void copy_symlink(const path& existing_symlink, const path& new_symlink,
270
  error_code& ec) noexcept;
271
  ```
272
 
273
  *Effects:* Equivalent to
274
  *`function`*`(read_symlink(existing_symlink), new_symlink)` or
@@ -279,12 +281,12 @@ respectively, where in each case *`function`* is `create_symlink` or
279
  *Throws:* As specified in  [[fs.err.report]].
280
 
281
  #### Create directories <a id="fs.op.create.directories">[[fs.op.create.directories]]</a>
282
 
283
  ``` cpp
284
- bool create_directories(const path& p);
285
- bool create_directories(const path& p, error_code& ec);
286
  ```
287
 
288
  *Effects:* Calls `create_directory()` for each element of `p` that does
289
  not exist.
290
 
@@ -296,12 +298,12 @@ resolves to, otherwise `false`.
296
  *Complexity:* 𝑂(n) where *n* is the number of elements of `p`.
297
 
298
  #### Create directory <a id="fs.op.create.directory">[[fs.op.create.directory]]</a>
299
 
300
  ``` cpp
301
- bool create_directory(const path& p);
302
- bool create_directory(const path& p, error_code& ec) noexcept;
303
  ```
304
 
305
  *Effects:* Creates the directory `p` resolves to, as if by POSIX `mkdir`
306
  with a second argument of `static_cast<int>(perms::all)`. If `mkdir`
307
  fails because `p` resolves to an existing directory, no error is
@@ -310,12 +312,12 @@ reported. Otherwise on failure an error is reported.
310
  *Returns:* `true` if a new directory was created, otherwise `false`.
311
 
312
  *Throws:* As specified in  [[fs.err.report]].
313
 
314
  ``` cpp
315
- bool create_directory(const path& p, const path& existing_p);
316
- bool create_directory(const path& p, const path& existing_p, error_code& ec) noexcept;
317
  ```
318
 
319
  *Effects:* Creates the directory `p` resolves to, with attributes copied
320
  from directory `existing_p`. The set of attributes copied is operating
321
  system dependent. If `mkdir` fails because `p` resolves to an existing
@@ -335,12 +337,12 @@ from directory `existing_p`, otherwise `false`.
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
 
@@ -348,24 +350,24 @@ void create_directory_symlink(const path& to, const path& new_symlink,
348
  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
 
@@ -383,12 +385,12 @@ 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
 
@@ -403,12 +405,12 @@ 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.
@@ -422,61 +424,61 @@ resolution for relative paths.
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 third-party
428
  or system library functions, or by another thread. — *end note*]
429
 
430
  ``` cpp
431
- void current_path(const path& p);
432
- void current_path(const path& p, error_code& ec) noexcept;
433
  ```
434
 
435
  *Effects:* Establishes the postcondition, as if by POSIX `chdir()`.
436
 
437
  *Ensures:* `equivalent(p, current_path())`.
438
 
439
  *Throws:* As specified in  [[fs.err.report]].
440
 
441
  [*Note 3*: The current path for many operating systems is a dangerous
442
- global state. It may be changed unexpectedly by a third-party or system
443
  library functions, or by another thread. — *end note*]
444
 
445
  #### Equivalent <a id="fs.op.equivalent">[[fs.op.equivalent]]</a>
446
 
447
  ``` cpp
448
- bool equivalent(const path& p1, const path& p2);
449
- bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
450
  ```
451
 
452
- *Returns:* `true`, if `p1` and `p2` resolve to the same file system
453
- entity, otherwise `false`. The signature with argument `ec` returns
454
- `false` if an error occurs.
455
-
456
  Two paths are considered to resolve to the same file system entity if
457
  two candidate entities reside on the same device at the same location.
458
 
459
  [*Note 1*: On POSIX platforms, this is determined as if by the values
460
  of the POSIX `stat` class, obtained as if by `stat()` for the two paths,
461
  having equal `st_dev` values and equal `st_ino` values. — *end note*]
462
 
 
 
 
 
 
 
463
  *Remarks:* `!exists(p1) || !exists(p2)` is an error.
464
 
465
- *Throws:* As specified in  [[fs.err.report]].
466
-
467
  #### Exists <a id="fs.op.exists">[[fs.op.exists]]</a>
468
 
469
  ``` cpp
470
- bool exists(file_status s) noexcept;
471
  ```
472
 
473
  *Returns:* `status_known(s) && s.type() != file_type::not_found`.
474
 
475
  ``` cpp
476
- bool exists(const path& p);
477
- bool exists(const path& p, error_code& ec) noexcept;
478
  ```
479
 
480
  Let `s` be a `file_status`, determined as if by `status(p)` or
481
  `status(p, ec)`, respectively.
482
 
@@ -488,12 +490,12 @@ Let `s` be a `file_status`, determined as if by `status(p)` or
488
  *Throws:* As specified in  [[fs.err.report]].
489
 
490
  #### File size <a id="fs.op.file.size">[[fs.op.file.size]]</a>
491
 
492
  ``` cpp
493
- uintmax_t file_size(const path& p);
494
- uintmax_t file_size(const path& p, error_code& ec) noexcept;
495
  ```
496
 
497
  *Effects:* If `exists(p)` is `false`, an error is
498
  reported [[fs.err.report]].
499
 
@@ -510,30 +512,30 @@ an error occurs.
510
  *Throws:* As specified in  [[fs.err.report]].
511
 
512
  #### Hard link count <a id="fs.op.hard.lk.ct">[[fs.op.hard.lk.ct]]</a>
513
 
514
  ``` cpp
515
- uintmax_t hard_link_count(const path& p);
516
- uintmax_t hard_link_count(const path& p, error_code& ec) noexcept;
517
  ```
518
 
519
  *Returns:* The number of hard links for `p`. The signature with argument
520
  `ec` returns `static_cast<uintmax_t>(-1)` if an error occurs.
521
 
522
  *Throws:* As specified in  [[fs.err.report]].
523
 
524
  #### Is block file <a id="fs.op.is.block.file">[[fs.op.is.block.file]]</a>
525
 
526
  ``` cpp
527
- bool is_block_file(file_status s) noexcept;
528
  ```
529
 
530
  *Returns:* `s.type() == file_type::block`.
531
 
532
  ``` cpp
533
- bool is_block_file(const path& p);
534
- bool is_block_file(const path& p, error_code& ec) noexcept;
535
  ```
536
 
537
  *Returns:* `is_block_file(status(p))` or `is_block_file(status(p, ec))`,
538
  respectively. The signature with argument `ec` returns `false` if an
539
  error occurs.
@@ -541,18 +543,18 @@ error occurs.
541
  *Throws:* As specified in  [[fs.err.report]].
542
 
543
  #### Is character file <a id="fs.op.is.char.file">[[fs.op.is.char.file]]</a>
544
 
545
  ``` cpp
546
- bool is_character_file(file_status s) noexcept;
547
  ```
548
 
549
  *Returns:* `s.type() == file_type::character`.
550
 
551
  ``` cpp
552
- bool is_character_file(const path& p);
553
- bool is_character_file(const path& p, error_code& ec) noexcept;
554
  ```
555
 
556
  *Returns:* `is_character_file(status(p))` or
557
  `is_character_file(status(p, ec))`, respectively.
558
  The signature with argument `ec` returns `false` if an error occurs.
@@ -560,18 +562,18 @@ The signature with argument `ec` returns `false` if an error occurs.
560
  *Throws:* As specified in  [[fs.err.report]].
561
 
562
  #### Is directory <a id="fs.op.is.directory">[[fs.op.is.directory]]</a>
563
 
564
  ``` cpp
565
- bool is_directory(file_status s) noexcept;
566
  ```
567
 
568
  *Returns:* `s.type() == file_type::directory`.
569
 
570
  ``` cpp
571
- bool is_directory(const path& p);
572
- bool is_directory(const path& p, error_code& ec) noexcept;
573
  ```
574
 
575
  *Returns:* `is_directory(status(p))` or `is_directory(status(p, ec))`,
576
  respectively. The signature with argument `ec` returns `false` if an
577
  error occurs.
@@ -579,12 +581,12 @@ error occurs.
579
  *Throws:* As specified in  [[fs.err.report]].
580
 
581
  #### Is empty <a id="fs.op.is.empty">[[fs.op.is.empty]]</a>
582
 
583
  ``` cpp
584
- bool is_empty(const path& p);
585
- bool is_empty(const path& p, error_code& ec);
586
  ```
587
 
588
  *Effects:*
589
 
590
  - Determine `file_status s`, as if by `status(p)` or `status(p, ec)`,
@@ -607,18 +609,18 @@ bool is_empty(const path& p, error_code& ec);
607
  *Throws:* As specified in  [[fs.err.report]].
608
 
609
  #### Is fifo <a id="fs.op.is.fifo">[[fs.op.is.fifo]]</a>
610
 
611
  ``` cpp
612
- bool is_fifo(file_status s) noexcept;
613
  ```
614
 
615
  *Returns:* `s.type() == file_type::fifo`.
616
 
617
  ``` cpp
618
- bool is_fifo(const path& p);
619
- bool is_fifo(const path& p, error_code& ec) noexcept;
620
  ```
621
 
622
  *Returns:* `is_fifo(status(p))` or `is_fifo(status(p, ec))`,
623
  respectively. The signature with argument `ec` returns `false` if an
624
  error occurs.
@@ -626,19 +628,19 @@ error occurs.
626
  *Throws:* As specified in  [[fs.err.report]].
627
 
628
  #### Is other <a id="fs.op.is.other">[[fs.op.is.other]]</a>
629
 
630
  ``` cpp
631
- bool is_other(file_status s) noexcept;
632
  ```
633
 
634
  *Returns:*
635
  `exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s)`.
636
 
637
  ``` cpp
638
- bool is_other(const path& p);
639
- bool is_other(const path& p, error_code& ec) noexcept;
640
  ```
641
 
642
  *Returns:* `is_other(status(p))` or `is_other(status(p, ec))`,
643
  respectively. The signature with argument `ec` returns `false` if an
644
  error occurs.
@@ -646,26 +648,26 @@ error occurs.
646
  *Throws:* As specified in  [[fs.err.report]].
647
 
648
  #### Is regular file <a id="fs.op.is.regular.file">[[fs.op.is.regular.file]]</a>
649
 
650
  ``` cpp
651
- bool is_regular_file(file_status s) noexcept;
652
  ```
653
 
654
  *Returns:* `s.type() == file_type::regular`.
655
 
656
  ``` cpp
657
- bool is_regular_file(const path& p);
658
  ```
659
 
660
  *Returns:* `is_regular_file(status(p))`.
661
 
662
  *Throws:* `filesystem_error` if `status(p)` would throw
663
  `filesystem_error`.
664
 
665
  ``` cpp
666
- bool is_regular_file(const path& p, error_code& ec) noexcept;
667
  ```
668
 
669
  *Effects:* Sets `ec` as if by `status(p, ec)`.
670
 
671
  [*Note 1*: `file_type::none`, `file_type::not_found` and
@@ -676,18 +678,18 @@ between cases, call the `status` function directly. — *end note*]
676
  occurs.
677
 
678
  #### Is socket <a id="fs.op.is.socket">[[fs.op.is.socket]]</a>
679
 
680
  ``` cpp
681
- bool is_socket(file_status s) noexcept;
682
  ```
683
 
684
  *Returns:* `s.type() == file_type::socket`.
685
 
686
  ``` cpp
687
- bool is_socket(const path& p);
688
- bool is_socket(const path& p, error_code& ec) noexcept;
689
  ```
690
 
691
  *Returns:* `is_socket(status(p))` or `is_socket(status(p, ec))`,
692
  respectively. The signature with argument `ec` returns `false` if an
693
  error occurs.
@@ -695,18 +697,18 @@ error occurs.
695
  *Throws:* As specified in  [[fs.err.report]].
696
 
697
  #### Is symlink <a id="fs.op.is.symlink">[[fs.op.is.symlink]]</a>
698
 
699
  ``` cpp
700
- bool is_symlink(file_status s) noexcept;
701
  ```
702
 
703
  *Returns:* `s.type() == file_type::symlink`.
704
 
705
  ``` cpp
706
- bool is_symlink(const path& p);
707
- bool is_symlink(const path& p, error_code& ec) noexcept;
708
  ```
709
 
710
  *Returns:* `is_symlink(symlink_status(p))` or
711
  `is_symlink(symlink_status(p, ec))`, respectively. The signature with
712
  argument `ec` returns `false` if an error occurs.
@@ -714,74 +716,74 @@ argument `ec` returns `false` if an error occurs.
714
  *Throws:* As specified in  [[fs.err.report]].
715
 
716
  #### Last write time <a id="fs.op.last.write.time">[[fs.op.last.write.time]]</a>
717
 
718
  ``` cpp
719
- file_time_type last_write_time(const path& p);
720
- file_time_type last_write_time(const path& p, error_code& ec) noexcept;
721
  ```
722
 
723
  *Returns:* The time of last data modification of `p`, determined as if
724
  by the value of the POSIX `stat` class member `st_mtime` obtained as if
725
  by POSIX `stat()`. The signature with argument `ec` returns
726
  `file_time_type::min()` if an error occurs.
727
 
728
  *Throws:* As specified in  [[fs.err.report]].
729
 
730
  ``` cpp
731
- void last_write_time(const path& p, file_time_type new_time);
732
- void last_write_time(const path& p, file_time_type new_time,
733
  error_code& ec) noexcept;
734
  ```
735
 
736
  *Effects:* Sets the time of last data modification of the file resolved
737
  to by `p` to `new_time`, as if by POSIX `futimens()`.
738
 
739
  *Throws:* As specified in  [[fs.err.report]].
740
 
741
  [*Note 1*: A postcondition of `last_write_time(p) == new_time` is not
742
- specified since it might not hold for file systems with coarse time
743
- granularity. — *end note*]
744
 
745
  #### Permissions <a id="fs.op.permissions">[[fs.op.permissions]]</a>
746
 
747
  ``` cpp
748
- void permissions(const path& p, perms prms, perm_options opts=perm_options::replace);
749
- void permissions(const path& p, perms prms, error_code& ec) noexcept;
750
- void permissions(const path& p, perms prms, perm_options opts, error_code& ec);
751
  ```
752
 
753
  *Preconditions:* Exactly one of the `perm_options` constants `replace`,
754
  `add`, or `remove` is present in `opts`.
755
 
756
- *Remarks:* The second signature behaves as if it had an additional
757
- parameter `perm_options` `opts` with an argument of
758
- `perm_options::replace`.
759
-
760
  *Effects:* Applies the action specified by `opts` to the file `p`
761
  resolves to, or to file `p` itself if `p` is a symbolic link and
762
  `perm_options::nofollow` is set in `opts`. The action is applied as if
763
  by POSIX `fchmodat()`.
764
 
765
  [*Note 1*: Conceptually permissions are viewed as bits, but the actual
766
- implementation may use some other mechanism. — *end note*]
767
 
768
  *Throws:* As specified in  [[fs.err.report]].
769
 
 
 
 
 
770
  #### Proximate <a id="fs.op.proximate">[[fs.op.proximate]]</a>
771
 
772
  ``` cpp
773
- path proximate(const path& p, error_code& ec);
774
  ```
775
 
776
  *Returns:* `proximate(p, current_path(), ec)`.
777
 
778
  *Throws:* As specified in  [[fs.err.report]].
779
 
780
  ``` cpp
781
- path proximate(const path& p, const path& base = current_path());
782
- path proximate(const path& p, const path& base, error_code& ec);
783
  ```
784
 
785
  *Returns:* For the first form:
786
 
787
  ``` cpp
@@ -799,12 +801,12 @@ or `path()` at the first error occurrence, if any.
799
  *Throws:* As specified in  [[fs.err.report]].
800
 
801
  #### Read symlink <a id="fs.op.read.symlink">[[fs.op.read.symlink]]</a>
802
 
803
  ``` cpp
804
- path read_symlink(const path& p);
805
- path read_symlink(const path& p, error_code& ec);
806
  ```
807
 
808
  *Returns:* If `p` resolves to a symbolic link, a `path` object
809
  containing the contents of that symbolic link. The signature with
810
  argument `ec` returns `path()` if an error occurs.
@@ -815,20 +817,20 @@ argument `ec` returns `path()` if an error occurs.
815
  link. — *end note*]
816
 
817
  #### Relative <a id="fs.op.relative">[[fs.op.relative]]</a>
818
 
819
  ``` cpp
820
- path relative(const path& p, error_code& ec);
821
  ```
822
 
823
  *Returns:* `relative(p, current_path(), ec)`.
824
 
825
  *Throws:* As specified in  [[fs.err.report]].
826
 
827
  ``` cpp
828
- path relative(const path& p, const path& base = current_path());
829
- path relative(const path& p, const path& base, error_code& ec);
830
  ```
831
 
832
  *Returns:* For the first form:
833
 
834
  ``` cpp
@@ -846,12 +848,12 @@ or `path()` at the first error occurrence, if any.
846
  *Throws:* As specified in  [[fs.err.report]].
847
 
848
  #### Remove <a id="fs.op.remove">[[fs.op.remove]]</a>
849
 
850
  ``` cpp
851
- bool remove(const path& p);
852
- bool remove(const path& p, error_code& ec) noexcept;
853
  ```
854
 
855
  *Effects:* If `exists(symlink_status(p, ec))`, the file `p` is removed
856
  as if by POSIX `remove()`.
857
 
@@ -866,12 +868,12 @@ with argument `ec` returns `false` if an error occurs.
866
  *Throws:* As specified in  [[fs.err.report]].
867
 
868
  #### Remove all <a id="fs.op.remove.all">[[fs.op.remove.all]]</a>
869
 
870
  ``` cpp
871
- uintmax_t remove_all(const path& p);
872
- uintmax_t remove_all(const path& p, error_code& ec);
873
  ```
874
 
875
  *Effects:* Recursively deletes the contents of `p` if it exists, then
876
  deletes file `p` itself, as if by POSIX `remove()`.
877
 
@@ -886,25 +888,25 @@ returns `static_cast< uintmax_t>(-1)` if an error occurs.
886
  *Throws:* As specified in  [[fs.err.report]].
887
 
888
  #### Rename <a id="fs.op.rename">[[fs.op.rename]]</a>
889
 
890
  ``` cpp
891
- void rename(const path& old_p, const path& new_p);
892
- void rename(const path& old_p, const path& new_p, error_code& ec) noexcept;
893
  ```
894
 
895
  *Effects:* Renames `old_p` to `new_p`, as if by POSIX `rename()`.
896
 
897
  [*Note 1*:
898
 
899
  - If `old_p` and `new_p` resolve to the same existing file, no action is
900
  taken.
901
- - Otherwise, the rename may include the following effects:
902
  - if `new_p` resolves to an existing non-directory file, `new_p` is
903
  removed; otherwise,
904
  - if `new_p` resolves to an existing directory, `new_p` is removed if
905
- empty on POSIX compliant operating systems but may be an error on
906
  other operating systems.
907
 
908
  A symbolic link is itself renamed, rather than the file it resolves to.
909
 
910
  — *end note*]
@@ -912,24 +914,24 @@ A symbolic link is itself renamed, rather than the file it resolves to.
912
  *Throws:* As specified in  [[fs.err.report]].
913
 
914
  #### Resize file <a id="fs.op.resize.file">[[fs.op.resize.file]]</a>
915
 
916
  ``` cpp
917
- void resize_file(const path& p, uintmax_t new_size);
918
- void resize_file(const path& p, uintmax_t new_size, error_code& ec) noexcept;
919
  ```
920
 
921
  *Effects:* Causes the size that would be returned by `file_size(p)` to
922
  be equal to `new_size`, as if by POSIX `truncate()`.
923
 
924
  *Throws:* As specified in  [[fs.err.report]].
925
 
926
  #### Space <a id="fs.op.space">[[fs.op.space]]</a>
927
 
928
  ``` cpp
929
- space_info space(const path& p);
930
- space_info space(const path& p, error_code& ec) noexcept;
931
  ```
932
 
933
  *Returns:* An object of type `space_info`. The value of the `space_info`
934
  object is determined as if by using POSIX `statvfs` to obtain a POSIX
935
  `struct statvfs`, and then multiplying its `f_blocks`, `f_bfree`, and
@@ -942,16 +944,16 @@ members are set to `static_cast<uintmax_t>(-1)` if an error occurs.
942
  *Throws:* As specified in  [[fs.err.report]].
943
 
944
  *Remarks:* The value of member `space_info::available` is operating
945
  system dependent.
946
 
947
- [*Note 1*: `available` may be less than `free`. — *end note*]
948
 
949
  #### Status <a id="fs.op.status">[[fs.op.status]]</a>
950
 
951
  ``` cpp
952
- file_status status(const path& p);
953
  ```
954
 
955
  *Effects:* As if:
956
 
957
  ``` cpp
@@ -969,11 +971,11 @@ return result;
969
  [*Note 1*: `result` values of `file_status(file_type::not_found)` and
970
  `file_status(file_type::unknown)` are not considered failures and do not
971
  cause an exception to be thrown. — *end note*]
972
 
973
  ``` cpp
974
- file_status status(const path& p, error_code& ec) noexcept;
975
  ```
976
 
977
  *Effects:* If possible, determines the attributes of the file `p`
978
  resolves to, as if by using POSIX `stat()` to obtain a POSIX
979
  `struct stat`. If, during attribute determination, the underlying file
@@ -1034,20 +1036,20 @@ determined as if by converting the `st_mode` member of the obtained
1034
  pathname resolution continues using the contents of the symbolic link.
1035
 
1036
  #### Status known <a id="fs.op.status.known">[[fs.op.status.known]]</a>
1037
 
1038
  ``` cpp
1039
- bool status_known(file_status s) noexcept;
1040
  ```
1041
 
1042
  *Returns:* `s.type() != file_type::none`.
1043
 
1044
  #### Symlink status <a id="fs.op.symlink.status">[[fs.op.symlink.status]]</a>
1045
 
1046
  ``` cpp
1047
- file_status symlink_status(const path& p);
1048
- file_status symlink_status(const path& p, error_code& ec) noexcept;
1049
  ```
1050
 
1051
  *Effects:* Same as `status()`, above, except that the attributes of `p`
1052
  are determined as if by using POSIX `lstat()` to obtain a POSIX
1053
  `struct stat`.
@@ -1059,19 +1061,19 @@ determined as if by converting the `st_mode` member of the obtained
1059
  *Returns:* Same as `status()`, above, except that if the attributes
1060
  indicate a symbolic link, as if by POSIX `S_ISLNK`, returns
1061
  `file_status(file_type::symlink, prms)`. The signature with argument
1062
  `ec` returns `file_status(file_type::none)` if an error occurs.
1063
 
 
 
1064
  *Remarks:* Pathname resolution terminates if `p` names a symbolic link.
1065
 
1066
- *Throws:* As specified in  [[fs.err.report]].
1067
-
1068
  #### Temporary directory path <a id="fs.op.temp.dir.path">[[fs.op.temp.dir.path]]</a>
1069
 
1070
  ``` cpp
1071
- path temp_directory_path();
1072
- path temp_directory_path(error_code& ec);
1073
  ```
1074
 
1075
  Let `p` be an unspecified directory path suitable for temporary files.
1076
 
1077
  *Effects:* If `exists(p)` is `false` or `is_directory(p)` is `false`, an
@@ -1090,17 +1092,14 @@ return the path reported by the Windows `GetTempPath` API
1090
  function. — *end example*]
1091
 
1092
  #### Weakly canonical <a id="fs.op.weakly.canonical">[[fs.op.weakly.canonical]]</a>
1093
 
1094
  ``` cpp
1095
- path weakly_canonical(const path& p);
1096
- path weakly_canonical(const path& p, error_code& ec);
1097
  ```
1098
 
1099
- *Returns:* `p` with symlinks resolved and the result
1100
- normalized [[fs.path.generic]].
1101
-
1102
  *Effects:* Using `status(p)` or `status(p, ec)`, respectively, to
1103
  determine existence, return a path composed by `operator/=` from the
1104
  result of calling `canonical()` with a path argument composed of the
1105
  leading elements of `p` that exist, if any, followed by the elements of
1106
  `p` that do not exist, if any. For the first form, `canonical()` is
@@ -1108,10 +1107,10 @@ called without an `error_code` argument. For the second form,
1108
  `canonical()` is called with `ec` as an `error_code` argument, and
1109
  `path()` is returned at the first error occurrence, if any.
1110
 
1111
  *Ensures:* The returned path is in normal form [[fs.path.generic]].
1112
 
1113
- *Remarks:* Implementations should avoid unnecessary normalization such
1114
- as when `canonical` has already been called on the entirety of `p`.
1115
 
1116
  *Throws:* As specified in  [[fs.err.report]].
1117
 
 
1
  ### Filesystem operation functions <a id="fs.op.funcs">[[fs.op.funcs]]</a>
2
 
3
+ #### General <a id="fs.op.funcs.general">[[fs.op.funcs.general]]</a>
4
+
5
  Filesystem operation functions query or modify files, including
6
  directories, in external storage.
7
 
8
  [*Note 1*: Because hardware failures, network failures, file system
9
  races [[fs.race.behavior]], and many other kinds of errors occur
10
+ frequently in file system operations, any filesystem operation function,
11
+ no matter how apparently innocuous, can encounter an error; see 
12
+ [[fs.err.report]]. — *end note*]
13
 
14
  #### Absolute <a id="fs.op.absolute">[[fs.op.absolute]]</a>
15
 
16
  ``` cpp
17
+ path filesystem::absolute(const path& p);
18
+ path filesystem::absolute(const path& p, error_code& ec);
19
  ```
20
 
21
  *Effects:* Composes an absolute path referencing the same file system
22
  location as `p` according to the operating system [[fs.conform.os]].
23
 
 
27
  [*Note 1*: For the returned path, `rp`, `rp.is_absolute()` is `true`
28
  unless an error occurs. — *end note*]
29
 
30
  *Throws:* As specified in  [[fs.err.report]].
31
 
32
+ [*Note 2*: To resolve symlinks or perform other sanitization that can
33
+ involve queries to secondary storage, such as hard disks, consider
34
  `canonical` [[fs.op.canonical]]. — *end note*]
35
 
36
  [*Note 3*: Implementations are strongly encouraged to not query
37
  secondary storage, and not consider `!exists(p)` an
38
  error. — *end note*]
 
43
  `GetFullPathNameW`. — *end example*]
44
 
45
  #### Canonical <a id="fs.op.canonical">[[fs.op.canonical]]</a>
46
 
47
  ``` cpp
48
+ path filesystem::canonical(const path& p);
49
+ path filesystem::canonical(const path& p, error_code& ec);
50
  ```
51
 
52
  *Effects:* Converts `p` to an absolute path that has no symbolic link,
53
  dot, or dot-dot elements in its pathname in the generic format.
54
 
 
61
  *Remarks:* `!exists(p)` is an error.
62
 
63
  #### Copy <a id="fs.op.copy">[[fs.op.copy]]</a>
64
 
65
  ``` cpp
66
+ void filesystem::copy(const path& from, const path& to);
67
  ```
68
 
69
  *Effects:* Equivalent to `copy(from, to, copy_options::none)`.
70
 
71
  ``` cpp
72
+ void filesystem::copy(const path& from, const path& to, error_code& ec);
73
  ```
74
 
75
  *Effects:* Equivalent to `copy(from, to, copy_options::none, ec)`.
76
 
77
  ``` cpp
78
+ void filesystem::copy(const path& from, const path& to, copy_options options);
79
+ void filesystem::copy(const path& from, const path& to, copy_options options,
80
  error_code& ec);
81
  ```
82
 
83
  *Preconditions:* At most one element from each option
84
  group [[fs.enum.copy.opts]] is set in `options`.
 
215
  — *end example*]
216
 
217
  #### Copy file <a id="fs.op.copy.file">[[fs.op.copy.file]]</a>
218
 
219
  ``` cpp
220
+ bool filesystem::copy_file(const path& from, const path& to);
221
+ bool filesystem::copy_file(const path& from, const path& to, error_code& ec);
222
  ```
223
 
224
  *Returns:* `copy_file(from, to, copy_options::none)` or
225
  `copy_file(from, to, copy_options::none, ec)`, respectively.
226
 
227
  *Throws:* As specified in  [[fs.err.report]].
228
 
229
  ``` cpp
230
+ bool filesystem::copy_file(const path& from, const path& to, copy_options options);
231
+ bool filesystem::copy_file(const path& from, const path& to, copy_options options,
232
  error_code& ec);
233
  ```
234
 
235
  *Preconditions:* At most one element from each option
236
  group [[fs.enum.copy.opts]] is set in `options`.
 
265
  *Complexity:* At most one direct or indirect invocation of `status(to)`.
266
 
267
  #### Copy symlink <a id="fs.op.copy.symlink">[[fs.op.copy.symlink]]</a>
268
 
269
  ``` cpp
270
+ void filesystem::copy_symlink(const path& existing_symlink, const path& new_symlink);
271
+ void filesystem::copy_symlink(const path& existing_symlink, const path& new_symlink,
272
  error_code& ec) noexcept;
273
  ```
274
 
275
  *Effects:* Equivalent to
276
  *`function`*`(read_symlink(existing_symlink), new_symlink)` or
 
281
  *Throws:* As specified in  [[fs.err.report]].
282
 
283
  #### Create directories <a id="fs.op.create.directories">[[fs.op.create.directories]]</a>
284
 
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
 
 
298
  *Complexity:* 𝑂(n) where *n* is the number of elements of `p`.
299
 
300
  #### Create directory <a id="fs.op.create.directory">[[fs.op.create.directory]]</a>
301
 
302
  ``` cpp
303
+ bool filesystem::create_directory(const path& p);
304
+ bool filesystem::create_directory(const path& p, error_code& ec) noexcept;
305
  ```
306
 
307
  *Effects:* Creates the directory `p` resolves to, as if by POSIX `mkdir`
308
  with a second argument of `static_cast<int>(perms::all)`. If `mkdir`
309
  fails because `p` resolves to an existing directory, no error is
 
312
  *Returns:* `true` if a new directory was created, otherwise `false`.
313
 
314
  *Throws:* As specified in  [[fs.err.report]].
315
 
316
  ``` cpp
317
+ bool filesystem::create_directory(const path& p, const path& existing_p);
318
+ bool filesystem::create_directory(const path& p, const path& existing_p, error_code& ec) noexcept;
319
  ```
320
 
321
  *Effects:* Creates the directory `p` resolves to, with attributes copied
322
  from directory `existing_p`. The set of attributes copied is operating
323
  system dependent. If `mkdir` fails because `p` resolves to an existing
 
337
  *Throws:* As specified in  [[fs.err.report]].
338
 
339
  #### Create directory symlink <a id="fs.op.create.dir.symlk">[[fs.op.create.dir.symlk]]</a>
340
 
341
  ``` cpp
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
 
 
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
357
+ directory 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*]
363
 
364
  #### Create hard link <a id="fs.op.create.hard.lk">[[fs.op.create.hard.lk]]</a>
365
 
366
  ``` cpp
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
 
 
385
  file. — *end note*]
386
 
387
  #### Create symlink <a id="fs.op.create.symlink">[[fs.op.create.symlink]]</a>
388
 
389
  ``` cpp
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
 
 
405
  operating system. — *end note*]
406
 
407
  #### Current path <a id="fs.op.current.path">[[fs.op.current.path]]</a>
408
 
409
  ``` cpp
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.
 
424
  [*Note 1*: The `current_path()` name was chosen to emphasize that 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 3*: The current path for many operating systems is a dangerous
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
 
449
  ``` cpp
450
+ bool filesystem::equivalent(const path& p1, const path& p2);
451
+ bool filesystem::equivalent(const path& p1, const path& p2, error_code& ec) noexcept;
452
  ```
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()` for the two paths,
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.
464
+
465
+ *Throws:* As specified in  [[fs.err.report]].
466
+
467
  *Remarks:* `!exists(p1) || !exists(p2)` is an error.
468
 
 
 
469
  #### Exists <a id="fs.op.exists">[[fs.op.exists]]</a>
470
 
471
  ``` cpp
472
+ bool filesystem::exists(file_status s) noexcept;
473
  ```
474
 
475
  *Returns:* `status_known(s) && s.type() != file_type::not_found`.
476
 
477
  ``` cpp
478
+ bool filesystem::exists(const path& p);
479
+ bool filesystem::exists(const path& p, error_code& ec) noexcept;
480
  ```
481
 
482
  Let `s` be a `file_status`, determined as if by `status(p)` or
483
  `status(p, ec)`, respectively.
484
 
 
490
  *Throws:* As specified in  [[fs.err.report]].
491
 
492
  #### File size <a id="fs.op.file.size">[[fs.op.file.size]]</a>
493
 
494
  ``` cpp
495
+ uintmax_t filesystem::file_size(const path& p);
496
+ uintmax_t filesystem::file_size(const path& p, error_code& ec) noexcept;
497
  ```
498
 
499
  *Effects:* If `exists(p)` is `false`, an error is
500
  reported [[fs.err.report]].
501
 
 
512
  *Throws:* As specified in  [[fs.err.report]].
513
 
514
  #### Hard link count <a id="fs.op.hard.lk.ct">[[fs.op.hard.lk.ct]]</a>
515
 
516
  ``` cpp
517
+ uintmax_t filesystem::hard_link_count(const path& p);
518
+ uintmax_t filesystem::hard_link_count(const path& p, error_code& ec) noexcept;
519
  ```
520
 
521
  *Returns:* The number of hard links for `p`. The signature with argument
522
  `ec` returns `static_cast<uintmax_t>(-1)` if an error occurs.
523
 
524
  *Throws:* As specified in  [[fs.err.report]].
525
 
526
  #### Is block file <a id="fs.op.is.block.file">[[fs.op.is.block.file]]</a>
527
 
528
  ``` cpp
529
+ bool filesystem::is_block_file(file_status s) noexcept;
530
  ```
531
 
532
  *Returns:* `s.type() == file_type::block`.
533
 
534
  ``` cpp
535
+ bool filesystem::is_block_file(const path& p);
536
+ bool filesystem::is_block_file(const path& p, error_code& ec) noexcept;
537
  ```
538
 
539
  *Returns:* `is_block_file(status(p))` or `is_block_file(status(p, ec))`,
540
  respectively. The signature with argument `ec` returns `false` if an
541
  error occurs.
 
543
  *Throws:* As specified in  [[fs.err.report]].
544
 
545
  #### Is character file <a id="fs.op.is.char.file">[[fs.op.is.char.file]]</a>
546
 
547
  ``` cpp
548
+ bool filesystem::is_character_file(file_status s) noexcept;
549
  ```
550
 
551
  *Returns:* `s.type() == file_type::character`.
552
 
553
  ``` cpp
554
+ bool filesystem::is_character_file(const path& p);
555
+ bool filesystem::is_character_file(const path& p, error_code& ec) noexcept;
556
  ```
557
 
558
  *Returns:* `is_character_file(status(p))` or
559
  `is_character_file(status(p, ec))`, respectively.
560
  The signature with argument `ec` returns `false` if an error occurs.
 
562
  *Throws:* As specified in  [[fs.err.report]].
563
 
564
  #### Is directory <a id="fs.op.is.directory">[[fs.op.is.directory]]</a>
565
 
566
  ``` cpp
567
+ bool filesystem::is_directory(file_status s) noexcept;
568
  ```
569
 
570
  *Returns:* `s.type() == file_type::directory`.
571
 
572
  ``` cpp
573
+ bool filesystem::is_directory(const path& p);
574
+ bool filesystem::is_directory(const path& p, error_code& ec) noexcept;
575
  ```
576
 
577
  *Returns:* `is_directory(status(p))` or `is_directory(status(p, ec))`,
578
  respectively. The signature with argument `ec` returns `false` if an
579
  error occurs.
 
581
  *Throws:* As specified in  [[fs.err.report]].
582
 
583
  #### Is empty <a id="fs.op.is.empty">[[fs.op.is.empty]]</a>
584
 
585
  ``` cpp
586
+ bool filesystem::is_empty(const path& p);
587
+ bool filesystem::is_empty(const path& p, error_code& ec);
588
  ```
589
 
590
  *Effects:*
591
 
592
  - Determine `file_status s`, as if by `status(p)` or `status(p, ec)`,
 
609
  *Throws:* As specified in  [[fs.err.report]].
610
 
611
  #### Is fifo <a id="fs.op.is.fifo">[[fs.op.is.fifo]]</a>
612
 
613
  ``` cpp
614
+ bool filesystem::is_fifo(file_status s) noexcept;
615
  ```
616
 
617
  *Returns:* `s.type() == file_type::fifo`.
618
 
619
  ``` cpp
620
+ bool filesystem::is_fifo(const path& p);
621
+ bool filesystem::is_fifo(const path& p, error_code& ec) noexcept;
622
  ```
623
 
624
  *Returns:* `is_fifo(status(p))` or `is_fifo(status(p, ec))`,
625
  respectively. The signature with argument `ec` returns `false` if an
626
  error occurs.
 
628
  *Throws:* As specified in  [[fs.err.report]].
629
 
630
  #### Is other <a id="fs.op.is.other">[[fs.op.is.other]]</a>
631
 
632
  ``` cpp
633
+ bool filesystem::is_other(file_status s) noexcept;
634
  ```
635
 
636
  *Returns:*
637
  `exists(s) && !is_regular_file(s) && !is_directory(s) && !is_symlink(s)`.
638
 
639
  ``` cpp
640
+ bool filesystem::is_other(const path& p);
641
+ bool filesystem::is_other(const path& p, error_code& ec) noexcept;
642
  ```
643
 
644
  *Returns:* `is_other(status(p))` or `is_other(status(p, ec))`,
645
  respectively. The signature with argument `ec` returns `false` if an
646
  error occurs.
 
648
  *Throws:* As specified in  [[fs.err.report]].
649
 
650
  #### Is regular file <a id="fs.op.is.regular.file">[[fs.op.is.regular.file]]</a>
651
 
652
  ``` cpp
653
+ bool filesystem::is_regular_file(file_status s) noexcept;
654
  ```
655
 
656
  *Returns:* `s.type() == file_type::regular`.
657
 
658
  ``` cpp
659
+ bool filesystem::is_regular_file(const path& p);
660
  ```
661
 
662
  *Returns:* `is_regular_file(status(p))`.
663
 
664
  *Throws:* `filesystem_error` if `status(p)` would throw
665
  `filesystem_error`.
666
 
667
  ``` cpp
668
+ bool filesystem::is_regular_file(const path& p, error_code& ec) noexcept;
669
  ```
670
 
671
  *Effects:* Sets `ec` as if by `status(p, ec)`.
672
 
673
  [*Note 1*: `file_type::none`, `file_type::not_found` and
 
678
  occurs.
679
 
680
  #### Is socket <a id="fs.op.is.socket">[[fs.op.is.socket]]</a>
681
 
682
  ``` cpp
683
+ bool filesystem::is_socket(file_status s) noexcept;
684
  ```
685
 
686
  *Returns:* `s.type() == file_type::socket`.
687
 
688
  ``` cpp
689
+ bool filesystem::is_socket(const path& p);
690
+ bool filesystem::is_socket(const path& p, error_code& ec) noexcept;
691
  ```
692
 
693
  *Returns:* `is_socket(status(p))` or `is_socket(status(p, ec))`,
694
  respectively. The signature with argument `ec` returns `false` if an
695
  error occurs.
 
697
  *Throws:* As specified in  [[fs.err.report]].
698
 
699
  #### Is symlink <a id="fs.op.is.symlink">[[fs.op.is.symlink]]</a>
700
 
701
  ``` cpp
702
+ bool filesystem::is_symlink(file_status s) noexcept;
703
  ```
704
 
705
  *Returns:* `s.type() == file_type::symlink`.
706
 
707
  ``` cpp
708
+ bool filesystem::is_symlink(const path& p);
709
+ bool filesystem::is_symlink(const path& p, error_code& ec) noexcept;
710
  ```
711
 
712
  *Returns:* `is_symlink(symlink_status(p))` or
713
  `is_symlink(symlink_status(p, ec))`, respectively. The signature with
714
  argument `ec` returns `false` if an error occurs.
 
716
  *Throws:* As specified in  [[fs.err.report]].
717
 
718
  #### Last write time <a id="fs.op.last.write.time">[[fs.op.last.write.time]]</a>
719
 
720
  ``` cpp
721
+ 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()`. The signature with argument `ec` returns
728
  `file_time_type::min()` if an error occurs.
729
 
730
  *Throws:* As specified in  [[fs.err.report]].
731
 
732
  ``` cpp
733
+ 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
745
+ coarse time granularity. — *end note*]
746
 
747
  #### Permissions <a id="fs.op.permissions">[[fs.op.permissions]]</a>
748
 
749
  ``` cpp
750
+ void filesystem::permissions(const path& p, perms prms, perm_options opts=perm_options::replace);
751
+ void filesystem::permissions(const path& p, perms prms, error_code& ec) noexcept;
752
+ void filesystem::permissions(const path& p, perms prms, perm_options opts, error_code& ec);
753
  ```
754
 
755
  *Preconditions:* Exactly one of the `perm_options` constants `replace`,
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]].
767
 
768
+ *Remarks:* The second signature behaves as if it had an additional
769
+ parameter `perm_options` `opts` with an argument of
770
+ `perm_options::replace`.
771
+
772
  #### Proximate <a id="fs.op.proximate">[[fs.op.proximate]]</a>
773
 
774
  ``` cpp
775
+ path filesystem::proximate(const path& p, error_code& ec);
776
  ```
777
 
778
  *Returns:* `proximate(p, current_path(), ec)`.
779
 
780
  *Throws:* As specified in  [[fs.err.report]].
781
 
782
  ``` cpp
783
+ path filesystem::proximate(const path& p, const path& base = current_path());
784
+ path filesystem::proximate(const path& p, const path& base, error_code& ec);
785
  ```
786
 
787
  *Returns:* For the first form:
788
 
789
  ``` cpp
 
801
  *Throws:* As specified in  [[fs.err.report]].
802
 
803
  #### Read symlink <a id="fs.op.read.symlink">[[fs.op.read.symlink]]</a>
804
 
805
  ``` cpp
806
+ path filesystem::read_symlink(const path& p);
807
+ path filesystem::read_symlink(const path& p, error_code& ec);
808
  ```
809
 
810
  *Returns:* If `p` resolves to a symbolic link, a `path` object
811
  containing the contents of that symbolic link. The signature with
812
  argument `ec` returns `path()` if an error occurs.
 
817
  link. — *end note*]
818
 
819
  #### Relative <a id="fs.op.relative">[[fs.op.relative]]</a>
820
 
821
  ``` cpp
822
+ path filesystem::relative(const path& p, error_code& ec);
823
  ```
824
 
825
  *Returns:* `relative(p, current_path(), ec)`.
826
 
827
  *Throws:* As specified in  [[fs.err.report]].
828
 
829
  ``` cpp
830
+ path filesystem::relative(const path& p, const path& base = current_path());
831
+ path filesystem::relative(const path& p, const path& base, error_code& ec);
832
  ```
833
 
834
  *Returns:* For the first form:
835
 
836
  ``` cpp
 
848
  *Throws:* As specified in  [[fs.err.report]].
849
 
850
  #### Remove <a id="fs.op.remove">[[fs.op.remove]]</a>
851
 
852
  ``` cpp
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
 
 
868
  *Throws:* As specified in  [[fs.err.report]].
869
 
870
  #### Remove all <a id="fs.op.remove.all">[[fs.op.remove.all]]</a>
871
 
872
  ``` cpp
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
 
 
888
  *Throws:* As specified in  [[fs.err.report]].
889
 
890
  #### Rename <a id="fs.op.rename">[[fs.op.rename]]</a>
891
 
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.
903
+ - Otherwise, the rename can include the following effects:
904
  - if `new_p` resolves to an existing non-directory file, `new_p` is
905
  removed; otherwise,
906
  - if `new_p` resolves to an existing directory, `new_p` is removed if
907
+ empty on POSIX compliant operating systems but might be an error on
908
  other operating systems.
909
 
910
  A symbolic link is itself renamed, rather than the file it resolves to.
911
 
912
  — *end note*]
 
914
  *Throws:* As specified in  [[fs.err.report]].
915
 
916
  #### Resize file <a id="fs.op.resize.file">[[fs.op.resize.file]]</a>
917
 
918
  ``` cpp
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
 
930
  ``` cpp
931
+ space_info filesystem::space(const path& p);
932
+ space_info filesystem::space(const path& p, error_code& ec) noexcept;
933
  ```
934
 
935
  *Returns:* An object of type `space_info`. The value of the `space_info`
936
  object is determined as if by using POSIX `statvfs` to obtain a POSIX
937
  `struct statvfs`, and then multiplying its `f_blocks`, `f_bfree`, and
 
944
  *Throws:* As specified in  [[fs.err.report]].
945
 
946
  *Remarks:* The value of member `space_info::available` is operating
947
  system dependent.
948
 
949
+ [*Note 1*: `available` might be less than `free`. — *end note*]
950
 
951
  #### Status <a id="fs.op.status">[[fs.op.status]]</a>
952
 
953
  ``` cpp
954
+ file_status filesystem::status(const path& p);
955
  ```
956
 
957
  *Effects:* As if:
958
 
959
  ``` cpp
 
971
  [*Note 1*: `result` values of `file_status(file_type::not_found)` and
972
  `file_status(file_type::unknown)` are not considered failures and do not
973
  cause an exception to be thrown. — *end note*]
974
 
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()` to obtain a POSIX
981
  `struct stat`. If, during attribute determination, the underlying file
 
1036
  pathname resolution continues using the contents of the symbolic link.
1037
 
1038
  #### Status known <a id="fs.op.status.known">[[fs.op.status.known]]</a>
1039
 
1040
  ``` cpp
1041
+ bool filesystem::status_known(file_status s) noexcept;
1042
  ```
1043
 
1044
  *Returns:* `s.type() != file_type::none`.
1045
 
1046
  #### Symlink status <a id="fs.op.symlink.status">[[fs.op.symlink.status]]</a>
1047
 
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()`, above, except that the attributes of `p`
1054
  are determined as if by using POSIX `lstat()` to obtain a POSIX
1055
  `struct stat`.
 
1061
  *Returns:* Same as `status()`, above, except that if the attributes
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]].
1067
+
1068
  *Remarks:* Pathname resolution terminates if `p` names a symbolic link.
1069
 
 
 
1070
  #### Temporary directory path <a id="fs.op.temp.dir.path">[[fs.op.temp.dir.path]]</a>
1071
 
1072
  ``` cpp
1073
+ path filesystem::temp_directory_path();
1074
+ path filesystem::temp_directory_path(error_code& ec);
1075
  ```
1076
 
1077
  Let `p` be an unspecified directory path suitable for temporary files.
1078
 
1079
  *Effects:* If `exists(p)` is `false` or `is_directory(p)` is `false`, an
 
1092
  function. — *end example*]
1093
 
1094
  #### Weakly canonical <a id="fs.op.weakly.canonical">[[fs.op.weakly.canonical]]</a>
1095
 
1096
  ``` cpp
1097
+ 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()` with a path argument composed of the
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()` is
 
1107
  `canonical()` is called with `ec` as an `error_code` argument, and
1108
  `path()` is returned at the first error occurrence, if any.
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]].
1114
 
1115
  *Throws:* As specified in  [[fs.err.report]].
1116