MCPcopy Create free account
hub / github.com/XorTroll/Goldleaf / CopyFileProgress

Method CopyFileProgress

Goldleaf/source/fs/fs_Explorer.cpp:132–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

StartCopyMethod · 0.80
CopyFileProgressFunction · 0.80
DoCopyDirectoryProgressFunction · 0.80

Calls 9

MakeFullMethod · 0.95
StartFileMethod · 0.95
ReadFileMethod · 0.95
EndFileMethod · 0.95
GetExplorerForPathFunction · 0.85
AllocateWorkBufferFunction · 0.85
DeleteWorkBufferFunction · 0.85
GetFileSizeMethod · 0.45
WriteFileMethod · 0.45

Tested by

no test coverage detected