Lines Matching refs:archive
92 uint64_t GetOwnerTag(const ZipArchive* archive) { in GetOwnerTag() argument
94 reinterpret_cast<uint64_t>(archive)); in GetOwnerTag()
153 static ZipError FindCentralDirectoryInfoForZip64(const char* debugFileName, ZipArchive* archive, in FindCentralDirectoryInfoForZip64() argument
162 if (!archive->mapped_zip.ReadAtOffset(reinterpret_cast<uint8_t*>((&zip64EocdLocator)), in FindCentralDirectoryInfoForZip64()
184 if (!archive->mapped_zip.ReadAtOffset(reinterpret_cast<uint8_t*>(&zip64EocdRecord), in FindCentralDirectoryInfoForZip64()
212 static ZipError FindCentralDirectoryInfo(const char* debug_file_name, ZipArchive* archive, in FindCentralDirectoryInfo() argument
218 if (!archive->mapped_zip.ReadAtOffset(scan_buffer.data(), read_amount, search_start)) { in FindCentralDirectoryInfo()
263 return FindCentralDirectoryInfoForZip64(debug_file_name, archive, eocd_offset, cdInfo); in FindCentralDirectoryInfo()
290 static ZipError MapCentralDirectory(const char* debug_file_name, ZipArchive* archive) { in MapCentralDirectory() argument
292 off64_t file_length = archive->mapped_zip.GetFileLength(); in MapCentralDirectory()
326 FindCentralDirectoryInfo(debug_file_name, archive, file_length, read_amount, &cdInfo); in MapCentralDirectory()
348 if (!archive->InitializeCentralDirectory(static_cast<off64_t>(cdInfo.cd_start_offset), in MapCentralDirectory()
353 archive->num_entries = cdInfo.num_records; in MapCentralDirectory()
354 archive->directory_offset = cdInfo.cd_start_offset; in MapCentralDirectory()
444 static ZipError ParseZipArchive(ZipArchive* archive) { in ParseZipArchive() argument
445 const uint8_t* const cd_ptr = archive->central_directory.GetBasePtr(); in ParseZipArchive()
446 const size_t cd_length = archive->central_directory.GetMapLength(); in ParseZipArchive()
447 const uint64_t num_entries = archive->num_entries; in ParseZipArchive()
450 archive->cd_entry_map = CdEntryMapZip32::Create(static_cast<uint16_t>(num_entries)); in ParseZipArchive()
452 archive->cd_entry_map = CdEntryMapZip64::Create(); in ParseZipArchive()
454 if (archive->cd_entry_map == nullptr) { in ParseZipArchive()
513 if (local_header_offset >= archive->directory_offset) { in ParseZipArchive()
528 archive->cd_entry_map->AddToMap(entry_name, archive->central_directory.GetBasePtr()); in ParseZipArchive()
542 if (!archive->mapped_zip.ReadAtOffset(reinterpret_cast<uint8_t*>(&lfh_start_bytes), in ParseZipArchive()
561 static int32_t OpenArchiveInternal(ZipArchive* archive, const char* debug_file_name) { in OpenArchiveInternal() argument
562 int32_t result = MapCentralDirectory(debug_file_name, archive); in OpenArchiveInternal()
563 return result != kSuccess ? result : ParseZipArchive(archive); in OpenArchiveInternal()
568 ZipArchive* archive = new ZipArchive(MappedZipFile(fd), assume_ownership); in OpenArchiveFd() local
569 *handle = archive; in OpenArchiveFd()
570 return OpenArchiveInternal(archive, debug_file_name); in OpenArchiveFd()
575 ZipArchive* archive = new ZipArchive(MappedZipFile(fd, length, offset), assume_ownership); in OpenArchiveFdRange() local
576 *handle = archive; in OpenArchiveFdRange()
588 return OpenArchiveInternal(archive, debug_file_name); in OpenArchiveFdRange()
593 ZipArchive* archive = new ZipArchive(MappedZipFile(fd), true); in OpenArchive() local
594 *handle = archive; in OpenArchive()
601 return OpenArchiveInternal(archive, fileName); in OpenArchive()
606 ZipArchive* archive = new ZipArchive(address, length); in OpenArchiveFromMemory() local
607 *handle = archive; in OpenArchiveFromMemory()
608 return OpenArchiveInternal(archive, debug_file_name); in OpenArchiveFromMemory()
611 ZipArchiveInfo GetArchiveInfo(ZipArchiveHandle archive) { in GetArchiveInfo() argument
613 result.archive_size = archive->mapped_zip.GetFileLength(); in GetArchiveInfo()
614 result.entry_count = archive->num_entries; in GetArchiveInfo()
621 void CloseArchive(ZipArchiveHandle archive) { in CloseArchive() argument
622 ALOGV("Closing archive %p", archive); in CloseArchive()
623 delete archive; in CloseArchive()
671 static int32_t FindEntry(const ZipArchive* archive, std::string_view entryName, in FindEntry() argument
676 const uint8_t* base_ptr = archive->central_directory.GetBasePtr(); in FindEntry()
683 if (ptr < base_ptr || ptr > base_ptr + archive->central_directory.GetMapLength()) { in FindEntry()
693 const off64_t cd_offset = archive->directory_offset; in FindEntry()
734 if (!archive->mapped_zip.ReadAtOffset(lfh_buf, sizeof(lfh_buf), local_header_offset)) { in FindEntry()
762 if (!archive->mapped_zip.ReadAtOffset(name_buf.data(), nameLen, name_offset)) { in FindEntry()
789 if (!archive->mapped_zip.ReadAtOffset(local_extra_field.data(), lfh_extra_field_size, in FindEntry()
888 ZipArchive* archive; member
894 IterationHandle(ZipArchive* archive, std::function<bool(std::string_view)> in_matcher) in IterationHandle()
895 : archive(archive), matcher(std::move(in_matcher)) {} in IterationHandle()
900 int32_t StartIteration(ZipArchiveHandle archive, void** cookie_ptr, in StartIteration() argument
912 return StartIteration(archive, cookie_ptr, std::move(matcher)); in StartIteration()
915 int32_t StartIteration(ZipArchiveHandle archive, void** cookie_ptr, in StartIteration() argument
917 if (archive == nullptr || archive->cd_entry_map == nullptr) { in StartIteration()
922 archive->cd_entry_map->ResetIteration(); in StartIteration()
923 *cookie_ptr = new IterationHandle(archive, matcher); in StartIteration()
946 int32_t FindEntry(const ZipArchiveHandle archive, const std::string_view entryName, in FindEntry() argument
949 if (auto status = FindEntry(archive, entryName, &entry64); status != kSuccess) { in FindEntry()
956 int32_t FindEntry(const ZipArchiveHandle archive, const std::string_view entryName, in FindEntry() argument
964 archive->cd_entry_map->GetCdEntryOffset(entryName, archive->central_directory.GetBasePtr()); in FindEntry()
970 return FindEntry(archive, entryName, offset, data); in FindEntry()
1007 ZipArchive* archive = handle->archive; in Next() local
1008 if (archive == nullptr || archive->cd_entry_map == nullptr) { in Next()
1013 auto entry = archive->cd_entry_map->Next(archive->central_directory.GetBasePtr()); in Next()
1017 const int error = FindEntry(archive, entry_name, offset, data); in Next()
1023 entry = archive->cd_entry_map->Next(archive->central_directory.GetBasePtr()); in Next()
1026 archive->cd_entry_map->ResetIteration(); in Next()
1384 int32_t ExtractToMemory(ZipArchiveHandle archive, const ZipEntry* entry, uint8_t* begin, in ExtractToMemory() argument
1387 return ExtractToMemory(archive, &entry64, begin, size); in ExtractToMemory()
1390 int32_t ExtractToMemory(ZipArchiveHandle archive, const ZipEntry64* entry, uint8_t* begin, in ExtractToMemory() argument
1397 return ExtractToWriter(archive, entry, writer.get()); in ExtractToMemory()
1400 int32_t ExtractEntryToFile(ZipArchiveHandle archive, const ZipEntry* entry, int fd) { in ExtractEntryToFile() argument
1402 return ExtractEntryToFile(archive, &entry64, fd); in ExtractEntryToFile()
1405 int32_t ExtractEntryToFile(ZipArchiveHandle archive, const ZipEntry64* entry, int fd) { in ExtractEntryToFile() argument
1411 return ExtractToWriter(archive, entry, writer.get()); in ExtractEntryToFile()
1414 int GetFileDescriptor(const ZipArchiveHandle archive) { in GetFileDescriptor() argument
1415 return archive->mapped_zip.GetFileDescriptor(); in GetFileDescriptor()
1418 off64_t GetFileDescriptorOffset(const ZipArchiveHandle archive) { in GetFileDescriptorOffset() argument
1419 return archive->mapped_zip.GetFileOffset(); in GetFileDescriptorOffset()
1437 int32_t ProcessZipEntryContents(ZipArchiveHandle archive, const ZipEntry* entry, in ProcessZipEntryContents() argument
1440 return ProcessZipEntryContents(archive, &entry64, func, cookie); in ProcessZipEntryContents()
1443 int32_t ProcessZipEntryContents(ZipArchiveHandle archive, const ZipEntry64* entry, in ProcessZipEntryContents() argument
1446 return ExtractToWriter(archive, entry, &writer); in ProcessZipEntryContents()