MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / SetFileData

Method SetFileData

src/openrct2/core/Zip.cpp:162–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 2

TitleSequenceSaveFunction · 0.45
TitleSequenceAddParkFunction · 0.45

Calls 4

valueMethod · 0.80
push_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected