| 130 | } |
| 131 | |
| 132 | void Explorer::CopyFileProgress(const std::string &path, const std::string &new_path, CopyFileStartCallback start_cb, CopyFileProgressCallback prog_cb) { |
| 133 | const auto full_path = this->MakeFull(path); |
| 134 | auto exp = GetExplorerForPath(new_path); |
| 135 | const auto full_new_path = exp->MakeFull(new_path); |
| 136 | auto work_buf = AllocateWorkBuffer(); |
| 137 | const auto file_size = this->GetFileSize(full_path); |
| 138 | start_cb(file_size); |
| 139 | auto rem_size = file_size; |
| 140 | u64 offset = 0; |
| 141 | this->StartFile(full_path, fs::FileMode::Read); |
| 142 | exp->StartFile(full_new_path, fs::FileMode::Write); |
| 143 | while(rem_size) { |
| 144 | const auto read_size = this->ReadFile(full_path, offset, std::min(rem_size, DefaultWorkBufferSize), work_buf); |
| 145 | rem_size -= read_size; |
| 146 | offset += read_size; |
| 147 | exp->WriteFile(full_new_path, work_buf, read_size); |
| 148 | prog_cb(read_size); |
| 149 | } |
| 150 | DeleteWorkBuffer(work_buf); |
| 151 | this->EndFile(); |
| 152 | exp->EndFile(); |
| 153 | } |
| 154 | |
| 155 | namespace { |
| 156 |
no test coverage detected