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

Method CopyFile

Goldleaf/source/fs/fs_Explorer.cpp:93–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91 }
92
93 void Explorer::CopyFile(const std::string &path, const std::string &new_path) {
94 const auto full_path = this->MakeFull(path);
95 auto exp = GetExplorerForPath(new_path);
96 const auto full_new_path = exp->MakeFull(new_path);
97 auto work_buf = AllocateWorkBuffer();
98 auto rem_size = this->GetFileSize(full_path);
99 u64 offset = 0;
100 this->StartFile(full_path, fs::FileMode::Read);
101 exp->StartFile(full_new_path, fs::FileMode::Write);
102 while(rem_size) {
103 const auto read_size = this->ReadFile(full_path, offset, std::min(rem_size, DefaultWorkBufferSize), work_buf);
104 rem_size -= read_size;
105 offset += read_size;
106 exp->WriteFile(new_path, work_buf, read_size);
107 }
108 DeleteWorkBuffer(work_buf);
109 this->EndFile();
110 exp->EndFile();
111 }
112
113 void Explorer::CopyDirectory(const std::string &dir, const std::string &new_dir) {
114 const auto full_dir = this->MakeFull(dir);

Callers 2

CopyDirectoryMethod · 0.95
PrepareInstallationMethod · 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