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

Method getFileDataAsString

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

Source from the content-addressed store, hash-verified

227}
228
229std::string ZipFile::getFileDataAsString(const std::string& filename) {
230 std::string buffer;
231 BLOCK_START {
232 BREAK_IF(!_file);
233 BREAK_IF(filename.empty());
234 std::string searchName = getSearchName(filename);
235 auto it = _file->fileList.find(searchName);
236 BREAK_IF(it == _file->fileList.end());
237 auto archive = &_file->archive;
238 size_t bufSize = s_cast<size_t>(it->second.size);
239 buffer.resize(bufSize);
240 if (!mz_zip_reader_extract_file_to_mem(archive, it->second.name.c_str(), buffer.data(), bufSize, 0)) {
241 auto err = mz_zip_get_error_string(mz_zip_get_last_error(archive));
242 Error("failed to extract file \"{}\" from zip: {}.", it->second.name, err);
243 }
244 }
245 BLOCK_END
246 return buffer;
247}

Callers 1

loadUnsafeMethod · 0.80

Calls 11

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
resizeMethod · 0.45
c_strMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected