Move off ZipString and over to std::string/std::string_view as appropriate.
Bug: http://b/129068177
Test: treehugger
Change-Id: Ib46761d89772d3a3c655a39df573fd305c117d19
diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp
index 61e3230..237c1e9 100644
--- a/libs/androidfw/ApkAssets.cpp
+++ b/libs/androidfw/ApkAssets.cpp
@@ -216,7 +216,7 @@
return false;
}
- ::ZipString name;
+ std::string name;
::ZipEntry entry;
// We need to hold back directories because many paths will contain them and we want to only
@@ -225,7 +225,7 @@
int32_t result;
while ((result = ::Next(cookie, &entry, &name)) == 0) {
- StringPiece full_file_path(reinterpret_cast<const char*>(name.name), name.name_length);
+ StringPiece full_file_path(name);
StringPiece leaf_file_path = full_file_path.substr(root_path_full.size());
if (!leaf_file_path.empty()) {
diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp
index ee5f778..e77ac3d 100644
--- a/libs/androidfw/ZipFileRO.cpp
+++ b/libs/androidfw/ZipFileRO.cpp
@@ -39,7 +39,7 @@
class _ZipEntryRO {
public:
ZipEntry entry;
- ZipString name;
+ std::string_view name;
void *cookie;
_ZipEntryRO() : cookie(NULL) {}
@@ -96,7 +96,7 @@
{
_ZipEntryRO* data = new _ZipEntryRO;
- data->name = ZipString(entryName);
+ data->name = entryName;
const int32_t error = FindEntry(mHandle, entryName, &(data->entry));
if (error) {
@@ -194,14 +194,14 @@
const
{
const _ZipEntryRO* zipEntry = reinterpret_cast<_ZipEntryRO*>(entry);
- const uint16_t requiredSize = zipEntry->name.name_length + 1;
+ const uint16_t requiredSize = zipEntry->name.length() + 1;
if (bufLen < requiredSize) {
ALOGW("Buffer too short, requires %d bytes for entry name", requiredSize);
return requiredSize;
}
- memcpy(buffer, zipEntry->name.name, requiredSize - 1);
+ memcpy(buffer, zipEntry->name.data(), requiredSize - 1);
buffer[requiredSize - 1] = '\0';
return 0;