1/* 2 * Copyright (c) 2024-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 SIGNATRUETOOLS_ZIP_UTILS_H 17#define SIGNATRUETOOLS_ZIP_UTILS_H 18 19#include <limits> 20#include <memory> 21 22#include "signature_tools_log.h" 23#include "zip_data_input.h" 24 25namespace OHOS { 26namespace SignatureTools { 27class ZipUtils { 28public: 29 ZipUtils() = delete; 30 /** 31 * set offset value of Central Directory to End of Central Directory Record. 32 * 33 * @param eocd buffer of End of Central Directory Record. 34 * @param offset offset value of Central Directory. 35 */ 36 static bool SetCentralDirectoryOffset(ByteBuffer& eocd, int64_t offset); 37 38private: 39 static constexpr int ZIP_CENTRAL_DIR_OFFSET_IN_EOCD = 16; 40 41 static constexpr int64_t UINT32_MAX_VALUE = 0xffffffffLL; 42 43 static bool SetUInt32ToBuffer(ByteBuffer& buffer, int offset, int64_t value); 44}; 45} // namespace SignatureTools 46} // namespace OHOS 47#endif // SIGNATRUETOOLS_ZIP_UTILS_H 48