1 /* 2 * Copyright (c) 2020 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 OHOS_GT_BUNDLE_EXTRACTOR_UTIL_H 17 #define OHOS_GT_BUNDLE_EXTRACTOR_UTIL_H 18 19 #include "stdint.h" 20 21 namespace OHOS { 22 class GtExtractorUtil { 23 public: 24 static uint8_t ExtractFileHeaderInfo(int32_t fp, char **bundleName); 25 static uint8_t ExtractFileToPath(const char *appInstallPath, int32_t fp, uint64_t &fileSize, char **fileName, 26 char **relativeFilePath); 27 static uint8_t ExtractFileAttr(int32_t fp, char **fileName, uint32_t &pathLen, uint64_t &fileSize); 28 static uint8_t ExtractFileAttr(int32_t fp, char **fileName, char **relativeFilePath, uint64_t &fileSize); 29 static bool CheckMagicNumber(int32_t fp); 30 static bool HasWrittenFile(const char *installPath, const char *path, const char *filename, int32_t fp, 31 uint64_t size); 32 private: 33 static uint32_t ReadInt(int32_t fp); 34 static uint64_t ReadLong(int32_t fp); 35 static unsigned char *ReadString(int32_t fp, uint32_t len); 36 static bool HasCopiedData(const char *filePath, int32_t fp, uint64_t size); 37 }; 38 } // namespace OHOS 39 40 extern "C" { 41 void RefreshAllServiceTimeStamp(void); 42 } 43 #endif // OHOS_GT_BUNDLE_EXTRACTOR_UTIL_H 44