| 160 | } |
| 161 | |
| 162 | void SetFileData(std::string_view path, std::vector<uint8_t>&& data) override |
| 163 | { |
| 164 | // Push buffer to an internal list as libzip requires access to it until the zip |
| 165 | // handle is closed. |
| 166 | _writeBuffers.push_back(std::move(data)); |
| 167 | const auto& writeBuffer = *_writeBuffers.rbegin(); |
| 168 | |
| 169 | auto source = zip_source_buffer(_zip, writeBuffer.data(), writeBuffer.size(), 0); |
| 170 | auto index = GetIndexFromPath(path); |
| 171 | zip_int64_t res = 0; |
| 172 | if (index.has_value()) |
| 173 | { |
| 174 | res = zip_file_replace(_zip, index.value(), source, 0); |
| 175 | } |
| 176 | else |
| 177 | { |
| 178 | res = zip_file_add(_zip, path.data(), source, 0); |
| 179 | } |
| 180 | if (res == -1) |
| 181 | { |
| 182 | zip_source_free(source); |
| 183 | throw std::runtime_error(std::string(zip_strerror(_zip))); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | void DeleteFile(std::string_view path) override |
| 188 | { |
no test coverage detected