diff options
Diffstat (limited to 'simpleperf/read_apk.cpp')
-rw-r--r-- | simpleperf/read_apk.cpp | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/simpleperf/read_apk.cpp b/simpleperf/read_apk.cpp index 8029dc53..18c76c23 100644 --- a/simpleperf/read_apk.cpp +++ b/simpleperf/read_apk.cpp @@ -31,29 +31,6 @@ #include "read_elf.h" #include "utils.h" -class ArchiveHelper { - public: - explicit ArchiveHelper(int fd, const std::string& debug_filename) : valid_(false) { - int rc = OpenArchiveFd(fd, "", &handle_, false); - if (rc == 0) { - valid_ = true; - } else { - LOG(ERROR) << "Failed to open archive " << debug_filename << ": " << ErrorCodeString(rc); - } - } - ~ArchiveHelper() { - if (valid_) { - CloseArchive(handle_); - } - } - bool valid() const { return valid_; } - ZipArchiveHandle &archive_handle() { return handle_; } - - private: - ZipArchiveHandle handle_; - bool valid_; -}; - std::map<ApkInspector::ApkOffset, std::unique_ptr<EmbeddedElf>> ApkInspector::embedded_elf_cache_; EmbeddedElf* ApkInspector::FindElfInApkByOffset(const std::string& apk_path, uint64_t file_offset) { @@ -75,13 +52,13 @@ std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByOffsetWithoutCache(cons if (!IsValidApkPath(apk_path)) { return nullptr; } - FileHelper fhelper(apk_path.c_str()); + FileHelper fhelper = FileHelper::OpenReadOnly(apk_path); if (!fhelper) { return nullptr; } ArchiveHelper ahelper(fhelper.fd(), apk_path); - if (!ahelper.valid()) { + if (!ahelper) { return nullptr; } ZipArchiveHandle &handle = ahelper.archive_handle(); @@ -135,12 +112,12 @@ std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByName(const std::string& if (!IsValidApkPath(apk_path)) { return nullptr; } - FileHelper fhelper(apk_path.c_str()); + FileHelper fhelper = FileHelper::OpenReadOnly(apk_path); if (!fhelper) { return nullptr; } ArchiveHelper ahelper(fhelper.fd(), apk_path); - if (!ahelper.valid()) { + if (!ahelper) { return nullptr; } ZipArchiveHandle& handle = ahelper.archive_handle(); |