| 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; |
no test coverage detected