Make StringPiece to be std::string_view alias
Bug: 237583012
Test: build + boot + UTs
Change-Id: I849831f4466d3b9c7ec842b75256e7fcba77a0c0
diff --git a/tools/aapt2/format/Archive.cpp b/tools/aapt2/format/Archive.cpp
index 80c1618..e9a93d8 100644
--- a/tools/aapt2/format/Archive.cpp
+++ b/tools/aapt2/format/Archive.cpp
@@ -40,8 +40,8 @@
public:
DirectoryWriter() = default;
- bool Open(const StringPiece& out_dir) {
- dir_ = out_dir.to_string();
+ bool Open(StringPiece out_dir) {
+ dir_ = std::string(out_dir);
file::FileType type = file::GetFileType(dir_);
if (type == file::FileType::kNonExistant) {
error_ = "directory does not exist";
@@ -53,14 +53,14 @@
return true;
}
- bool StartEntry(const StringPiece& path, uint32_t flags) override {
+ bool StartEntry(StringPiece path, uint32_t flags) override {
if (file_) {
return false;
}
std::string full_path = dir_;
file::AppendPath(&full_path, path);
- file::mkdirs(file::GetStem(full_path).to_string());
+ file::mkdirs(std::string(file::GetStem(full_path)));
file_ = {::android::base::utf8::fopen(full_path.c_str(), "wb"), fclose};
if (!file_) {
@@ -91,7 +91,7 @@
return true;
}
- bool WriteFile(const StringPiece& path, uint32_t flags, io::InputStream* in) override {
+ bool WriteFile(StringPiece path, uint32_t flags, io::InputStream* in) override {
if (!StartEntry(path, flags)) {
return false;
}
@@ -132,8 +132,8 @@
public:
ZipFileWriter() = default;
- bool Open(const StringPiece& path) {
- file_ = {::android::base::utf8::fopen(path.to_string().c_str(), "w+b"), fclose};
+ bool Open(StringPiece path) {
+ file_ = {::android::base::utf8::fopen(path.data(), "w+b"), fclose};
if (!file_) {
error_ = SystemErrorCodeToString(errno);
return false;
@@ -142,7 +142,7 @@
return true;
}
- bool StartEntry(const StringPiece& path, uint32_t flags) override {
+ bool StartEntry(StringPiece path, uint32_t flags) override {
if (!writer_) {
return false;
}
@@ -182,7 +182,7 @@
return true;
}
- bool WriteFile(const StringPiece& path, uint32_t flags, io::InputStream* in) override {
+ bool WriteFile(StringPiece path, uint32_t flags, io::InputStream* in) override {
while (true) {
if (!StartEntry(path, flags)) {
return false;
@@ -257,7 +257,7 @@
} // namespace
std::unique_ptr<IArchiveWriter> CreateDirectoryArchiveWriter(android::IDiagnostics* diag,
- const StringPiece& path) {
+ StringPiece path) {
std::unique_ptr<DirectoryWriter> writer = util::make_unique<DirectoryWriter>();
if (!writer->Open(path)) {
diag->Error(android::DiagMessage(path) << writer->GetError());
@@ -267,7 +267,7 @@
}
std::unique_ptr<IArchiveWriter> CreateZipFileArchiveWriter(android::IDiagnostics* diag,
- const StringPiece& path) {
+ StringPiece path) {
std::unique_ptr<ZipFileWriter> writer = util::make_unique<ZipFileWriter>();
if (!writer->Open(path)) {
diag->Error(android::DiagMessage(path) << writer->GetError());