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

Method SaveFile

Goldleaf/source/fs/fs_PFS0.cpp:100–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 }
99
100 void PFS0::SaveFile(const u32 idx, fs::Explorer *path_exp, const std::string &path) {
101 if(IsInvalidFileIndex(idx) || (idx >= this->files.size())) {
102 return;
103 }
104
105 const auto file_size = this->GetFileSize(idx);
106 auto work_buf = fs::AllocateWorkBuffer();
107 auto rem_size = file_size;
108 u64 off = 0;
109 path_exp->DeleteFile(path);
110 path_exp->CreateFile(path);
111 this->exp->StartFile(this->path, fs::FileMode::Read);
112 path_exp->StartFile(path, fs::FileMode::Write);
113 while(rem_size) {
114 const auto read_size = this->ReadFromFile(idx, off, std::min(fs::DefaultWorkBufferSize, rem_size), work_buf);
115 path_exp->WriteFile(path, work_buf, read_size);
116 off += read_size;
117 rem_size -= read_size;
118 }
119 this->exp->EndFile();
120 path_exp->EndFile();
121 fs::DeleteWorkBuffer(work_buf);
122 }
123
124 u32 PFS0::GetFileIndexByName(const std::string &file_name) {
125 u32 idx = 0;

Callers 1

PrepareInstallationMethod · 0.80

Calls 9

GetFileSizeMethod · 0.95
ReadFromFileMethod · 0.95
AllocateWorkBufferFunction · 0.85
DeleteWorkBufferFunction · 0.85
StartFileMethod · 0.80
EndFileMethod · 0.80
DeleteFileMethod · 0.45
CreateFileMethod · 0.45
WriteFileMethod · 0.45

Tested by

no test coverage detected