| 142 | } |
| 143 | |
| 144 | static void asyncCopy( |
| 145 | IDisk & from_disk, |
| 146 | String from_path, |
| 147 | IDisk & to_disk, |
| 148 | String to_path, |
| 149 | ThreadPoolCallbackRunnerLocal<void> & runner, |
| 150 | const ReadSettings & read_settings, |
| 151 | const WriteSettings & write_settings, |
| 152 | const std::function<void()> & cancellation_hook) |
| 153 | { |
| 154 | if (from_disk.existsFile(from_path)) |
| 155 | { |
| 156 | runner.enqueueAndKeepTrack( |
| 157 | [&from_disk, from_path, &to_disk, to_path, &read_settings, &write_settings, &cancellation_hook] { |
| 158 | from_disk.copyFile( |
| 159 | from_path, to_disk, to_path, read_settings, write_settings, cancellation_hook); |
| 160 | }); |
| 161 | } |
| 162 | else /// Directory |
| 163 | { |
| 164 | fs::path dest(to_path); |
| 165 | to_disk.createDirectories(dest); |
| 166 | |
| 167 | /// Calling asyncCopy recursively is fine here. Each call will capture by reference what were already references |
| 168 | /// dest is an exception, but it's passed as value, not reference |
| 169 | for (auto it = from_disk.iterateDirectory(from_path); it->isValid(); it->next()) |
| 170 | asyncCopy(from_disk, it->path(), to_disk, dest / it->name(), runner, read_settings, write_settings, cancellation_hook); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | void IDisk::copyThroughBuffers( |
| 175 | const String & from_path, |
no test coverage detected