diff options
| author | 2018-04-27 13:16:32 +0200 | |
|---|---|---|
| committer | 2018-10-30 04:37:41 -0700 | |
| commit | 0275123eefcb823cd32df20191dd83eccdebdcbf (patch) | |
| tree | 440eb37286eff3cd2fba4616ffedf21b9983b17f /cmds/idmap2/include | |
| parent | 8c12dcd11a18081b365d81267c3d29f9848222f9 (diff) | |
idmap2: initial code drop
idmap2 is a reboot of the idmap project. The project aims to
- use modern C++
- greatly improve test and debug support
- interface towards AssetManager2 (instead of AssetManager)
- provide a solid foundation to add support for new features
To make it easier to verify correctness, this first version of idmap2 is
feature equivalent to idmap. Later versions will add support for new
features such as <overlayable>.
Bug: 78815803
Test: make idmap2_tests
Change-Id: I1d806dc875a493e730ab55d2fdb027618e586d16
Diffstat (limited to 'cmds/idmap2/include')
| -rw-r--r-- | cmds/idmap2/include/idmap2/BinaryStreamVisitor.h | 49 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/CommandLineOptions.h | 71 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/FileUtils.h | 41 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/Idmap.h | 277 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/PrettyPrintVisitor.h | 53 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/RawPrintVisitor.h | 59 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/ResourceUtils.h | 39 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/Xml.h | 51 | ||||
| -rw-r--r-- | cmds/idmap2/include/idmap2/ZipFile.h | 62 |
9 files changed, 702 insertions, 0 deletions
diff --git a/cmds/idmap2/include/idmap2/BinaryStreamVisitor.h b/cmds/idmap2/include/idmap2/BinaryStreamVisitor.h new file mode 100644 index 000000000000..2368aeadbc9f --- /dev/null +++ b/cmds/idmap2/include/idmap2/BinaryStreamVisitor.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_BINARYSTREAMVISITOR_H_ +#define IDMAP2_INCLUDE_IDMAP2_BINARYSTREAMVISITOR_H_ + +#include <cstdint> +#include <iostream> +#include <string> + +#include "idmap2/Idmap.h" + +namespace android { +namespace idmap2 { + +class BinaryStreamVisitor : public Visitor { + public: + explicit BinaryStreamVisitor(std::ostream& stream) : stream_(stream) { + } + virtual void visit(const Idmap& idmap); + virtual void visit(const IdmapHeader& header); + virtual void visit(const IdmapData& data); + virtual void visit(const IdmapData::Header& header); + virtual void visit(const IdmapData::TypeEntry& type_entry); + + private: + void Write16(uint16_t value); + void Write32(uint32_t value); + void WriteString(const StringPiece& value); + std::ostream& stream_; +}; + +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_BINARYSTREAMVISITOR_H_ diff --git a/cmds/idmap2/include/idmap2/CommandLineOptions.h b/cmds/idmap2/include/idmap2/CommandLineOptions.h new file mode 100644 index 000000000000..f3aa68b8d1a2 --- /dev/null +++ b/cmds/idmap2/include/idmap2/CommandLineOptions.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_COMMANDLINEOPTIONS_H_ +#define IDMAP2_INCLUDE_IDMAP2_COMMANDLINEOPTIONS_H_ + +#include <functional> +#include <memory> +#include <ostream> +#include <string> +#include <vector> + +namespace android { +namespace idmap2 { + +/* + * Utility class to convert a command line, including options (--path foo.txt), + * into data structures (options.path = "foo.txt"). + */ +class CommandLineOptions { + public: + static std::unique_ptr<std::vector<std::string>> ConvertArgvToVector(int argc, const char** argv); + + explicit CommandLineOptions(const std::string& name) : name_(name) { + } + + CommandLineOptions& OptionalFlag(const std::string& name, const std::string& description, + bool* value); + CommandLineOptions& MandatoryOption(const std::string& name, const std::string& description, + std::string* value); + CommandLineOptions& MandatoryOption(const std::string& name, const std::string& description, + std::vector<std::string>* value); + CommandLineOptions& OptionalOption(const std::string& name, const std::string& description, + std::string* value); + bool Parse(const std::vector<std::string>& argv, std::ostream& outError) const; + void Usage(std::ostream& out) const; + + private: + struct Option { + std::string name; + std::string description; + std::function<void(const std::string& value)> action; + enum { + COUNT_OPTIONAL, + COUNT_EXACTLY_ONCE, + COUNT_ONCE_OR_MORE, + } count; + bool argument; + }; + + mutable std::vector<Option> options_; + std::string name_; +}; + +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_COMMANDLINEOPTIONS_H_ diff --git a/cmds/idmap2/include/idmap2/FileUtils.h b/cmds/idmap2/include/idmap2/FileUtils.h new file mode 100644 index 000000000000..05c6d31d395d --- /dev/null +++ b/cmds/idmap2/include/idmap2/FileUtils.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_FILEUTILS_H_ +#define IDMAP2_INCLUDE_IDMAP2_FILEUTILS_H_ + +#include <functional> +#include <memory> +#include <string> +#include <vector> + +namespace android { +namespace idmap2 { +namespace utils { +typedef std::function<bool(unsigned char type /* DT_* from dirent.h */, const std::string& path)> + FindFilesPredicate; +std::unique_ptr<std::vector<std::string>> FindFiles(const std::string& root, bool recurse, + const FindFilesPredicate& predicate); + +std::unique_ptr<std::string> ReadFile(int fd); + +std::unique_ptr<std::string> ReadFile(const std::string& path); + +} // namespace utils +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_FILEUTILS_H_ diff --git a/cmds/idmap2/include/idmap2/Idmap.h b/cmds/idmap2/include/idmap2/Idmap.h new file mode 100644 index 000000000000..837b7c5264d5 --- /dev/null +++ b/cmds/idmap2/include/idmap2/Idmap.h @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * # idmap file format (current version) + * + * idmap := header data* + * header := magic version target_crc overlay_crc target_path overlay_path + * data := data_header data_block* + * data_header := target_package_id types_count + * data_block := target_type overlay_type entry_count entry_offset entry* + * overlay_path := string + * target_path := string + * entry := <uint32_t> + * entry_count := <uint16_t> + * entry_offset := <uint16_t> + * magic := <uint32_t> + * overlay_crc := <uint32_t> + * overlay_type := <uint16_t> + * string := <uint8_t>[256] + * target_crc := <uint32_t> + * target_package_id := <uint16_t> + * target_type := <uint16_t> + * types_count := <uint16_t> + * version := <uint32_t> + * + * + * # idmap file format changelog + * ## v1 + * - Identical to idmap v1. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_IDMAP_H_ +#define IDMAP2_INCLUDE_IDMAP2_IDMAP_H_ + +#include <iostream> +#include <memory> +#include <string> +#include <vector> + +#include "android-base/macros.h" + +#include "androidfw/ApkAssets.h" +#include "androidfw/ResourceTypes.h" +#include "androidfw/StringPiece.h" + +namespace android { +namespace idmap2 { + +class Idmap; +class Visitor; + +// use typedefs to let the compiler warn us about implicit casts +typedef uint32_t ResourceId; // 0xpptteeee +typedef uint8_t PackageId; // pp in 0xpptteeee +typedef uint8_t TypeId; // tt in 0xpptteeee +typedef uint16_t EntryId; // eeee in 0xpptteeee + +static constexpr const ResourceId kPadding = 0xffffffffu; + +static constexpr const EntryId kNoEntry = 0xffffu; + +// magic number: all idmap files start with this +static constexpr const uint32_t kIdmapMagic = android::kIdmapMagic; + +// current version of the idmap binary format; must be incremented when the format is changed +static constexpr const uint32_t kIdmapCurrentVersion = android::kIdmapCurrentVersion; + +// strings in the idmap are encoded char arrays of length 'kIdmapStringLength' (including mandatory +// terminating null) +static constexpr const size_t kIdmapStringLength = 256; + +class IdmapHeader { + public: + static std::unique_ptr<const IdmapHeader> FromBinaryStream(std::istream& stream); + + inline uint32_t GetMagic() const { + return magic_; + } + + inline uint32_t GetVersion() const { + return version_; + } + + inline uint32_t GetTargetCrc() const { + return target_crc_; + } + + inline uint32_t GetOverlayCrc() const { + return overlay_crc_; + } + + inline StringPiece GetTargetPath() const { + return StringPiece(target_path_); + } + + inline StringPiece GetOverlayPath() const { + return StringPiece(overlay_path_); + } + + // Invariant: anytime the idmap data encoding is changed, the idmap version + // field *must* be incremented. Because of this, we know that if the idmap + // header is up-to-date the entire file is up-to-date. + bool IsUpToDate(std::ostream& out_error) const; + + void accept(Visitor* v) const; + + private: + IdmapHeader() { + } + + uint32_t magic_; + uint32_t version_; + uint32_t target_crc_; + uint32_t overlay_crc_; + char target_path_[kIdmapStringLength]; + char overlay_path_[kIdmapStringLength]; + + friend Idmap; + DISALLOW_COPY_AND_ASSIGN(IdmapHeader); +}; + +class IdmapData { + public: + class Header { + public: + static std::unique_ptr<const Header> FromBinaryStream(std::istream& stream); + + inline PackageId GetTargetPackageId() const { + return target_package_id_; + } + + inline uint16_t GetTypeCount() const { + return type_count_; + } + + void accept(Visitor* v) const; + + private: + Header() { + } + + PackageId target_package_id_; + uint16_t type_count_; + + friend Idmap; + DISALLOW_COPY_AND_ASSIGN(Header); + }; + + class TypeEntry { + public: + static std::unique_ptr<const TypeEntry> FromBinaryStream(std::istream& stream); + + inline TypeId GetTargetTypeId() const { + return target_type_id_; + } + + inline TypeId GetOverlayTypeId() const { + return overlay_type_id_; + } + + inline uint16_t GetEntryCount() const { + return entries_.size(); + } + + inline uint16_t GetEntryOffset() const { + return entry_offset_; + } + + inline EntryId GetEntry(size_t i) const { + return i < entries_.size() ? entries_[i] : 0xffffu; + } + + void accept(Visitor* v) const; + + private: + TypeEntry() { + } + + TypeId target_type_id_; + TypeId overlay_type_id_; + uint16_t entry_offset_; + std::vector<EntryId> entries_; + + friend Idmap; + DISALLOW_COPY_AND_ASSIGN(TypeEntry); + }; + + static std::unique_ptr<const IdmapData> FromBinaryStream(std::istream& stream); + + inline const std::unique_ptr<const Header>& GetHeader() const { + return header_; + } + + inline const std::vector<std::unique_ptr<const TypeEntry>>& GetTypeEntries() const { + return type_entries_; + } + + void accept(Visitor* v) const; + + private: + IdmapData() { + } + + std::unique_ptr<const Header> header_; + std::vector<std::unique_ptr<const TypeEntry>> type_entries_; + + friend Idmap; + DISALLOW_COPY_AND_ASSIGN(IdmapData); +}; + +class Idmap { + public: + static std::string CanonicalIdmapPathFor(const std::string& absolute_dir, + const std::string& absolute_apk_path); + + static std::unique_ptr<const Idmap> FromBinaryStream(std::istream& stream, + std::ostream& out_error); + + // In the current version of idmap, the first package in each resources.arsc + // file is used; change this in the next version of idmap to use a named + // package instead; also update FromApkAssets to take additional parameters: + // the target and overlay package names + static std::unique_ptr<const Idmap> FromApkAssets(const std::string& target_apk_path, + const ApkAssets& target_apk_assets, + const std::string& overlay_apk_path, + const ApkAssets& overlay_apk_assets, + std::ostream& out_error); + + inline const std::unique_ptr<const IdmapHeader>& GetHeader() const { + return header_; + } + + inline const std::vector<std::unique_ptr<const IdmapData>>& GetData() const { + return data_; + } + + void accept(Visitor* v) const; + + private: + Idmap() { + } + + std::unique_ptr<const IdmapHeader> header_; + std::vector<std::unique_ptr<const IdmapData>> data_; + + DISALLOW_COPY_AND_ASSIGN(Idmap); +}; + +class Visitor { + public: + virtual ~Visitor() { + } + virtual void visit(const Idmap& idmap) = 0; + virtual void visit(const IdmapHeader& header) = 0; + virtual void visit(const IdmapData& data) = 0; + virtual void visit(const IdmapData::Header& header) = 0; + virtual void visit(const IdmapData::TypeEntry& type_entry) = 0; +}; + +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_IDMAP_H_ diff --git a/cmds/idmap2/include/idmap2/PrettyPrintVisitor.h b/cmds/idmap2/include/idmap2/PrettyPrintVisitor.h new file mode 100644 index 000000000000..c388f4b94251 --- /dev/null +++ b/cmds/idmap2/include/idmap2/PrettyPrintVisitor.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_PRETTYPRINTVISITOR_H_ +#define IDMAP2_INCLUDE_IDMAP2_PRETTYPRINTVISITOR_H_ + +#include <iostream> +#include <memory> + +#include "androidfw/AssetManager2.h" + +#include "idmap2/Idmap.h" + +namespace android { + +class ApkAssets; + +namespace idmap2 { + +class PrettyPrintVisitor : public Visitor { + public: + explicit PrettyPrintVisitor(std::ostream& stream) : stream_(stream) { + } + virtual void visit(const Idmap& idmap); + virtual void visit(const IdmapHeader& header); + virtual void visit(const IdmapData& data); + virtual void visit(const IdmapData::Header& header); + virtual void visit(const IdmapData::TypeEntry& type_entry); + + private: + std::ostream& stream_; + std::unique_ptr<const ApkAssets> target_apk_; + AssetManager2 target_am_; + PackageId last_seen_package_id_; +}; + +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_PRETTYPRINTVISITOR_H_ diff --git a/cmds/idmap2/include/idmap2/RawPrintVisitor.h b/cmds/idmap2/include/idmap2/RawPrintVisitor.h new file mode 100644 index 000000000000..7e33b3b06fc3 --- /dev/null +++ b/cmds/idmap2/include/idmap2/RawPrintVisitor.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_RAWPRINTVISITOR_H_ +#define IDMAP2_INCLUDE_IDMAP2_RAWPRINTVISITOR_H_ + +#include <iostream> +#include <memory> +#include <string> + +#include "androidfw/AssetManager2.h" + +#include "idmap2/Idmap.h" + +namespace android { + +class ApkAssets; + +namespace idmap2 { + +class RawPrintVisitor : public Visitor { + public: + explicit RawPrintVisitor(std::ostream& stream) : stream_(stream), offset_(0) { + } + virtual void visit(const Idmap& idmap); + virtual void visit(const IdmapHeader& header); + virtual void visit(const IdmapData& data); + virtual void visit(const IdmapData::Header& header); + virtual void visit(const IdmapData::TypeEntry& type_entry); + + private: + void print(uint16_t value, const char* fmt, ...); + void print(uint32_t value, const char* fmt, ...); + void print(const std::string& value, const char* fmt, ...); + + std::ostream& stream_; + std::unique_ptr<const ApkAssets> target_apk_; + AssetManager2 target_am_; + size_t offset_; + PackageId last_seen_package_id_; +}; + +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_RAWPRINTVISITOR_H_ diff --git a/cmds/idmap2/include/idmap2/ResourceUtils.h b/cmds/idmap2/include/idmap2/ResourceUtils.h new file mode 100644 index 000000000000..88a835b6439c --- /dev/null +++ b/cmds/idmap2/include/idmap2/ResourceUtils.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_RESOURCEUTILS_H_ +#define IDMAP2_INCLUDE_IDMAP2_RESOURCEUTILS_H_ + +#include <string> +#include <utility> + +#include "android-base/macros.h" +#include "androidfw/AssetManager2.h" + +#include "idmap2/Idmap.h" + +namespace android { +namespace idmap2 { +namespace utils { + +std::pair<bool, std::string> WARN_UNUSED ResToTypeEntryName(const AssetManager2& am, + ResourceId resid); + +} // namespace utils +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_RESOURCEUTILS_H_ diff --git a/cmds/idmap2/include/idmap2/Xml.h b/cmds/idmap2/include/idmap2/Xml.h new file mode 100644 index 000000000000..9ab5ec454750 --- /dev/null +++ b/cmds/idmap2/include/idmap2/Xml.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_XML_H_ +#define IDMAP2_INCLUDE_IDMAP2_XML_H_ + +#include <map> +#include <memory> +#include <string> + +#include "android-base/macros.h" +#include "androidfw/ResourceTypes.h" +#include "utils/String16.h" + +namespace android { +namespace idmap2 { + +class Xml { + public: + static std::unique_ptr<const Xml> Create(const uint8_t* data, size_t size, bool copyData = false); + + std::unique_ptr<std::map<std::string, std::string>> FindTag(const std::string& name) const; + + ~Xml(); + + private: + Xml() { + } + + mutable ResXMLTree xml_; + + DISALLOW_COPY_AND_ASSIGN(Xml); +}; + +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_XML_H_ diff --git a/cmds/idmap2/include/idmap2/ZipFile.h b/cmds/idmap2/include/idmap2/ZipFile.h new file mode 100644 index 000000000000..328bd367adfc --- /dev/null +++ b/cmds/idmap2/include/idmap2/ZipFile.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDMAP2_INCLUDE_IDMAP2_ZIPFILE_H_ +#define IDMAP2_INCLUDE_IDMAP2_ZIPFILE_H_ + +#include <memory> +#include <string> +#include <utility> + +#include "android-base/macros.h" +#include "ziparchive/zip_archive.h" + +namespace android { +namespace idmap2 { + +struct MemoryChunk { + size_t size; + uint8_t buf[0]; + + static std::unique_ptr<MemoryChunk> Allocate(size_t size); + + private: + MemoryChunk() { + } +}; + +class ZipFile { + public: + static std::unique_ptr<const ZipFile> Open(const std::string& path); + + std::unique_ptr<const MemoryChunk> Uncompress(const std::string& entryPath) const; + std::pair<bool, uint32_t> Crc(const std::string& entryPath) const; + + ~ZipFile(); + + private: + explicit ZipFile(const ::ZipArchiveHandle handle) : handle_(handle) { + } + + const ::ZipArchiveHandle handle_; + + DISALLOW_COPY_AND_ASSIGN(ZipFile); +}; + +} // namespace idmap2 +} // namespace android + +#endif // IDMAP2_INCLUDE_IDMAP2_ZIPFILE_H_ |