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| 7 |
+
*Effects:* Equivalent to `copy(from, to, copy_options::none)`.
|
| 8 |
+
|
| 9 |
+
``` cpp
|
| 10 |
+
void copy(const path& from, const path& to, error_code& ec) noexcept;
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
*Effects:* Equivalent to `copy(from, to, copy_options::none, ec)`.
|
| 14 |
+
|
| 15 |
+
``` cpp
|
| 16 |
+
void copy(const path& from, const path& to, copy_options options);
|
| 17 |
+
void copy(const path& from, const path& to, copy_options options,
|
| 18 |
+
error_code& ec) noexcept;
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
*Requires:* At most one element from each option group
|
| 22 |
+
([[fs.enum.copy.opts]]) is set in `options`.
|
| 23 |
+
|
| 24 |
+
*Effects:* Before the first use of `f` and `t`:
|
| 25 |
+
|
| 26 |
+
- If
|
| 27 |
+
``` cpp
|
| 28 |
+
(options & copy_options::create_symlinks) != copy_options::none ||
|
| 29 |
+
(options & copy_options::skip_symlinks) != copy_options::none
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
then `auto f = symlink_status(from)` and if needed
|
| 33 |
+
`auto t = symlink_status(to)`.
|
| 34 |
+
- Otherwise, if
|
| 35 |
+
``` cpp
|
| 36 |
+
(options & copy_options::copy_symlinks) != copy_options::none
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
then `auto f = symlink_status(from)` and if needed
|
| 40 |
+
`auto t = status(to)`.
|
| 41 |
+
- Otherwise, `auto f = status(from)` and if needed
|
| 42 |
+
`auto t = status(to)`.
|
| 43 |
+
|
| 44 |
+
Effects are then as follows:
|
| 45 |
+
|
| 46 |
+
- If `f.type()` or `t.type()` is an implementation-defined file
|
| 47 |
+
type ([[fs.enum.file_type]]), then the effects are
|
| 48 |
+
*implementation-defined*.
|
| 49 |
+
- Otherwise, an error is reported as specified in [[fs.err.report]] if:
|
| 50 |
+
- `!exists(f)`, or
|
| 51 |
+
- `equivalent(from, to)`, or
|
| 52 |
+
- `is_other(f) || is_other(t)`, or
|
| 53 |
+
- `is_directory(f) && is_regular_file(t)`.
|
| 54 |
+
- Otherwise, if `is_symlink(f)`, then:
|
| 55 |
+
- If `(options & copy_options::skip_symlinks) != copy_options::none`
|
| 56 |
+
then return.
|
| 57 |
+
- Otherwise if
|
| 58 |
+
``` cpp
|
| 59 |
+
!exists(t) && (options & copy_options::copy_symlinks) != copy_options::none
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
then `copy_symlink(from, to)`.
|
| 63 |
+
- Otherwise report an error as specified in [[fs.err.report]].
|
| 64 |
+
- Otherwise, if `is_regular_file(f)`, then:
|
| 65 |
+
- If
|
| 66 |
+
`(options & copy_options::directories_only) != copy_options::none`,
|
| 67 |
+
then return.
|
| 68 |
+
- Otherwise, if
|
| 69 |
+
`(options & copy_options::create_symlinks) `` != copy_options::none`,
|
| 70 |
+
then create a symbolic link to the source file.
|
| 71 |
+
- Otherwise, if
|
| 72 |
+
`(options & copy_options::create_hard_links) != copy_options::none`,
|
| 73 |
+
then create a hard link to the source file.
|
| 74 |
+
- Otherwise, if `is_directory(t)`, then
|
| 75 |
+
`copy_file(from, to/from.filename(), options)`.
|
| 76 |
+
- Otherwise, `copy_file(from, to, options)`.
|
| 77 |
+
- Otherwise, if
|
| 78 |
+
``` cpp
|
| 79 |
+
is_directory(f) &&
|
| 80 |
+
((options & copy_options::recursive) != copy_options::none ||
|
| 81 |
+
options == copy_options::none)
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
then:
|
| 85 |
+
- If `!exists(t)`, then `create_directory(to, from)`.
|
| 86 |
+
- Then, iterate over the files in `from`, as if by
|
| 87 |
+
``` cpp
|
| 88 |
+
for (const directory_entry& x : directory_iterator(from))
|
| 89 |
+
copy(x.path(), to/x.path().filename(), options | copy_options::unspecified)
|
| 90 |
+
```
|
| 91 |
+
- Otherwise, for the signature with argument `ec`, `ec.clear()`.
|
| 92 |
+
- Otherwise, no effects.
|
| 93 |
+
|
| 94 |
+
*Throws:* As specified in [[fs.err.report]].
|
| 95 |
+
|
| 96 |
+
*Remarks:* For the signature with argument `ec`, any library functions
|
| 97 |
+
called by the implementation shall have an `error_code` argument if
|
| 98 |
+
applicable.
|
| 99 |
+
|
| 100 |
+
[*Example 1*:
|
| 101 |
+
|
| 102 |
+
Given this directory structure:
|
| 103 |
+
|
| 104 |
+
``` cpp
|
| 105 |
+
/dir1
|
| 106 |
+
file1
|
| 107 |
+
file2
|
| 108 |
+
dir2
|
| 109 |
+
file3
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
Calling `copy("/dir1", "/dir3")` would result in:
|
| 113 |
+
|
| 114 |
+
``` cpp
|
| 115 |
+
/dir1
|
| 116 |
+
file1
|
| 117 |
+
file2
|
| 118 |
+
dir2
|
| 119 |
+
file3
|
| 120 |
+
/dir3
|
| 121 |
+
file1
|
| 122 |
+
file2
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
Alternatively, calling `copy("/dir1", "/dir3", copy_options::recursive)`
|
| 126 |
+
would result in:
|
| 127 |
+
|
| 128 |
+
``` cpp
|
| 129 |
+
/dir1
|
| 130 |
+
file1
|
| 131 |
+
file2
|
| 132 |
+
dir2
|
| 133 |
+
file3
|
| 134 |
+
/dir3
|
| 135 |
+
file1
|
| 136 |
+
file2
|
| 137 |
+
dir2
|
| 138 |
+
file3
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
— *end example*]
|
| 142 |
+
|