Loading libziparchive/include/ziparchive/zip_archive.h +4 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <sys/cdefs.h> #include <sys/types.h> #include <string> #include <string_view> #include "android-base/off64_t.h" Loading @@ -35,6 +36,7 @@ enum { kCompressDeflated = 8, // standard deflate }; // TODO: remove this when everyone's moved over to std::string. struct ZipString { const uint8_t* name; uint16_t name_length; Loading Loading @@ -187,6 +189,8 @@ int32_t StartIteration(ZipArchiveHandle archive, void** cookie_ptr, * Returns 0 on success, -1 if there are no more elements in this * archive and lower negative values on failure. */ int32_t Next(void* cookie, ZipEntry* data, std::string* name); // TODO: remove this when everyone's moved over to std::string. int32_t Next(void* cookie, ZipEntry* data, ZipString* name); /* Loading libziparchive/unzip.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -255,9 +255,8 @@ static void ProcessAll(ZipArchiveHandle zah) { } ZipEntry entry; ZipString string; while ((err = Next(cookie, &entry, &string)) >= 0) { std::string name(string.name, string.name + string.name_length); std::string name; while ((err = Next(cookie, &entry, &name)) >= 0) { if (ShouldInclude(name)) ProcessOne(zah, entry, name); } Loading libziparchive/zip_archive.cc +9 −0 Original line number Diff line number Diff line Loading @@ -747,6 +747,15 @@ int32_t FindEntry(const ZipArchiveHandle archive, const std::string_view entryNa return FindEntry(archive, static_cast<uint32_t>(ent), data); } int32_t Next(void* cookie, ZipEntry* data, std::string* name) { ZipString zs; int32_t result = Next(cookie, data, &zs); if (result == 0) { *name = std::string(reinterpret_cast<const char*>(zs.name), zs.name_length); } return result; } int32_t Next(void* cookie, ZipEntry* data, ZipString* name) { IterationHandle* handle = reinterpret_cast<IterationHandle*>(cookie); if (handle == NULL) { Loading libziparchive/zip_archive_benchmark.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ static void Iterate_all_files(benchmark::State& state) { ZipArchiveHandle handle; void* iteration_cookie; ZipEntry data; ZipString name; std::string name; while (state.KeepRunning()) { OpenArchive(temp_file->path, &handle); Loading libziparchive/zip_archive_test.cc +4 −4 Original line number Diff line number Diff line Loading @@ -118,10 +118,10 @@ static void AssertIterationOrder(const std::string_view prefix, const std::strin ZipEntry data; std::vector<std::string> names; ZipString name; std::string name; for (size_t i = 0; i < expected_names_sorted.size(); ++i) { ASSERT_EQ(0, Next(iteration_cookie, &data, &name)); names.push_back(std::string(reinterpret_cast<const char*>(name.name), name.name_length)); names.push_back(name); } // End of iteration. Loading Loading @@ -167,7 +167,7 @@ TEST(ziparchive, IterationWithBadPrefixAndSuffix) { ASSERT_EQ(0, StartIteration(handle, &iteration_cookie, "x", "y")); ZipEntry data; ZipString name; std::string name; // End of iteration. ASSERT_EQ(-1, Next(iteration_cookie, &data, &name)); Loading Loading @@ -224,7 +224,7 @@ TEST(ziparchive, TestInvalidDeclaredLength) { void* iteration_cookie; ASSERT_EQ(0, StartIteration(handle, &iteration_cookie)); ZipString name; std::string name; ZipEntry data; ASSERT_EQ(Next(iteration_cookie, &data, &name), 0); Loading Loading
libziparchive/include/ziparchive/zip_archive.h +4 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <sys/cdefs.h> #include <sys/types.h> #include <string> #include <string_view> #include "android-base/off64_t.h" Loading @@ -35,6 +36,7 @@ enum { kCompressDeflated = 8, // standard deflate }; // TODO: remove this when everyone's moved over to std::string. struct ZipString { const uint8_t* name; uint16_t name_length; Loading Loading @@ -187,6 +189,8 @@ int32_t StartIteration(ZipArchiveHandle archive, void** cookie_ptr, * Returns 0 on success, -1 if there are no more elements in this * archive and lower negative values on failure. */ int32_t Next(void* cookie, ZipEntry* data, std::string* name); // TODO: remove this when everyone's moved over to std::string. int32_t Next(void* cookie, ZipEntry* data, ZipString* name); /* Loading
libziparchive/unzip.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -255,9 +255,8 @@ static void ProcessAll(ZipArchiveHandle zah) { } ZipEntry entry; ZipString string; while ((err = Next(cookie, &entry, &string)) >= 0) { std::string name(string.name, string.name + string.name_length); std::string name; while ((err = Next(cookie, &entry, &name)) >= 0) { if (ShouldInclude(name)) ProcessOne(zah, entry, name); } Loading
libziparchive/zip_archive.cc +9 −0 Original line number Diff line number Diff line Loading @@ -747,6 +747,15 @@ int32_t FindEntry(const ZipArchiveHandle archive, const std::string_view entryNa return FindEntry(archive, static_cast<uint32_t>(ent), data); } int32_t Next(void* cookie, ZipEntry* data, std::string* name) { ZipString zs; int32_t result = Next(cookie, data, &zs); if (result == 0) { *name = std::string(reinterpret_cast<const char*>(zs.name), zs.name_length); } return result; } int32_t Next(void* cookie, ZipEntry* data, ZipString* name) { IterationHandle* handle = reinterpret_cast<IterationHandle*>(cookie); if (handle == NULL) { Loading
libziparchive/zip_archive_benchmark.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ static void Iterate_all_files(benchmark::State& state) { ZipArchiveHandle handle; void* iteration_cookie; ZipEntry data; ZipString name; std::string name; while (state.KeepRunning()) { OpenArchive(temp_file->path, &handle); Loading
libziparchive/zip_archive_test.cc +4 −4 Original line number Diff line number Diff line Loading @@ -118,10 +118,10 @@ static void AssertIterationOrder(const std::string_view prefix, const std::strin ZipEntry data; std::vector<std::string> names; ZipString name; std::string name; for (size_t i = 0; i < expected_names_sorted.size(); ++i) { ASSERT_EQ(0, Next(iteration_cookie, &data, &name)); names.push_back(std::string(reinterpret_cast<const char*>(name.name), name.name_length)); names.push_back(name); } // End of iteration. Loading Loading @@ -167,7 +167,7 @@ TEST(ziparchive, IterationWithBadPrefixAndSuffix) { ASSERT_EQ(0, StartIteration(handle, &iteration_cookie, "x", "y")); ZipEntry data; ZipString name; std::string name; // End of iteration. ASSERT_EQ(-1, Next(iteration_cookie, &data, &name)); Loading Loading @@ -224,7 +224,7 @@ TEST(ziparchive, TestInvalidDeclaredLength) { void* iteration_cookie; ASSERT_EQ(0, StartIteration(handle, &iteration_cookie)); ZipString name; std::string name; ZipEntry data; ASSERT_EQ(Next(iteration_cookie, &data, &name), 0); Loading