summaryrefslogtreecommitdiffstats
path: root/zipwrap.hpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2017-09-08 13:50:54 +0200
committerEthan Yonker <dees_troy@teamw.in>2017-09-08 14:14:59 +0200
commit8373cfe28cf1b5ad758faa1d502e21787c3665e4 (patch)
tree2f567c52cd6f89e1052481497d236b58d230b7e2 /zipwrap.hpp
parentDO NOT MERGE Android 8.0 stuff (diff)
parentrelease-request-f4ecf242-5d1c-45e0-8c7c-ede48d1a9e82-for-git_oc-release-4111650 snap-temp-L02200000075283731 (diff)
downloadandroid_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.gz
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.bz2
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.lz
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.xz
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.tar.zst
android_bootable_recovery-8373cfe28cf1b5ad758faa1d502e21787c3665e4.zip
Diffstat (limited to 'zipwrap.hpp')
-rw-r--r--zipwrap.hpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/zipwrap.hpp b/zipwrap.hpp
new file mode 100644
index 000000000..f86e98e43
--- /dev/null
+++ b/zipwrap.hpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 bigbiff/Dees_Troy TeamWin
+ * This file is part of TWRP/TeamWin Recovery 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 __ZIPWRAP_HPP
+#define __ZIPWRAP_HPP
+
+#include <string>
+#ifdef USE_MINZIP
+#include "minzip/Zip.h"
+#include "minzip/SysUtil.h"
+#else
+#include <ziparchive/zip_archive.h>
+#include "otautil/SysUtil.h"
+#endif
+
+using namespace std;
+
+class ZipWrap {
+ public:
+ ZipWrap();
+ ~ZipWrap();
+
+ bool Open(const char* file, MemMapping* map);
+ void Close();
+ bool EntryExists(const string& filename);
+ bool ExtractEntry(const string& source_file, const string& target_file, mode_t mode);
+
+ long GetUncompressedSize(const string& filename);
+ bool ExtractToBuffer(const string& filename, uint8_t* begin);
+ bool ExtractRecursive(const string& source_dir, const string& target_dir);
+#ifdef USE_MINZIP
+ loff_t GetEntryOffset(const string& filename);
+#else
+ off64_t GetEntryOffset(const string& filename);
+ ZipArchiveHandle GetZipArchiveHandle();
+#endif
+
+ private:
+#ifdef USE_MINZIP
+ ZipArchive Zip;
+#else
+ ZipArchiveHandle Zip;
+#endif
+ string zip_file;
+ bool zip_open;
+};
+
+#endif //__ZIPWRAP_HPP