Merge "Move off the Next ZipString overload." am: 0c0afe17e9

am: 1bb5ac584b

Change-Id: I1e35353c86aad938ca4b1f30ed5edb9a9b516330
This commit is contained in:
Elliott Hughes 2019-05-23 13:10:52 -07:00 committed by android-build-merger
commit e0ee594385

View file

@ -37,7 +37,7 @@ static void usage() {
fprintf(stderr, " The output zip file that will be created from the input file.\n");
}
using ZipData = std::pair<std::unique_ptr<ZipEntry>, std::unique_ptr<ZipString>>;
using ZipData = std::pair<std::unique_ptr<ZipEntry>, std::string>;
static bool GetEntries(ZipArchiveHandle handle, std::vector<ZipData>* entries) {
void* cookie;
@ -48,10 +48,9 @@ static bool GetEntries(ZipArchiveHandle handle, std::vector<ZipData>* entries) {
}
ZipEntry entry;
ZipString name;
std::string name;
while ((return_value = Next(cookie, &entry, &name)) == 0) {
entries->emplace_back(std::make_pair(std::make_unique<ZipEntry>(entry),
std::make_unique<ZipString>(name)));
entries->emplace_back(std::make_pair(std::make_unique<ZipEntry>(entry), name));
}
if (return_value != -1) {
fprintf(stderr, "Error while iterating over zip entries: %s\n", ErrorCodeString(return_value));
@ -78,13 +77,12 @@ static bool CreateAlignedZip(ZipArchiveHandle& handle, FILE* zip_dst, uint32_t a
int32_t error;
for (auto& entry : entries) {
ZipEntry* zip_entry = entry.first.get();
ZipString* zip_str = entry.second.get();
std::string& zip_name = entry.second;
size_t flags = 0;
if ((zip_entry->method & kCompressDeflated) != 0) {
flags |= ZipWriter::kCompress;
}
std::string zip_name(reinterpret_cast<const char*>(zip_str->name), zip_str->name_length);
error = writer.StartAlignedEntry(zip_name.c_str(), flags, alignment);
if (error != 0) {
fprintf(stderr, "StartAlignedEntry failed: %s\n", ZipWriter::ErrorCodeString(error));