MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / getFileDataUnsafe

Method getFileDataUnsafe

Source/3rdParty/Zip/ZipUtils.cpp:207–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207uint8_t* ZipFile::getFileDataUnsafe(const std::string& filename, size_t* size) {
208 uint8_t* buffer = nullptr;
209 if (size) *size = 0;
210 BLOCK_START {
211 BREAK_IF(!_file);
212 BREAK_IF(filename.empty());
213 std::string searchName = getSearchName(filename);
214 auto it = _file->fileList.find(searchName);
215 BREAK_IF(it == _file->fileList.end());
216 auto archive = &_file->archive;
217 size_t bufSize = s_cast<size_t>(it->second.size);
218 if (size) *size = bufSize;
219 buffer = new uint8_t[bufSize];
220 if (!mz_zip_reader_extract_file_to_mem(archive, it->second.name.c_str(), buffer, bufSize, 0)) {
221 auto err = mz_zip_get_error_string(mz_zip_get_last_error(archive));
222 Error("failed to extract file \"{}\" from zip: {}.", it->second.name, err);
223 }
224 }
225 BLOCK_END
226 return buffer;
227}

Callers 1

loadUnsafeMethod · 0.80

Calls 9

getSearchNameFunction · 0.85
mz_zip_get_error_stringFunction · 0.70
mz_zip_get_last_errorFunction · 0.70
findMethod · 0.65
ErrorEnum · 0.50
emptyMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected