1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_UNZIP_WRAPPER_H 17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_UNZIP_WRAPPER_H 18 19 #include <filesystem> 20 21 #include "zip_constants.h" 22 23 namespace OHOS { 24 namespace AppPackingTool { 25 class UnzipWrapper { 26 public: 27 UnzipWrapper(); 28 explicit UnzipWrapper(std::string path); 29 virtual ~UnzipWrapper(); 30 31 UnzipWrapper(const UnzipWrapper &) = delete; 32 UnzipWrapper &operator=(const UnzipWrapper &) = delete; 33 34 int32_t Open(std::string& unzPath); 35 int32_t Open(); 36 void Close(); 37 int32_t UnzipFile(std::string filePath); 38 IsOpen()39 bool IsOpen() const 40 { 41 return (unzFile_ != nullptr); 42 } 43 44 protected: 45 std::string ExtractFile(const std::string filePath); 46 47 private: 48 unzFile unzFile_ = nullptr; 49 unz_global_info64 unzGlobalInfo_ = { 0, 0 }; 50 std::string unzFilePath_; 51 }; 52 } // namespace AppPackingTool 53 } // namespace OHOS 54 #endif // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_UNZIP_WRAPPER_H 55