• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ENTRY_H
17 #define SIGNATRUETOOLS_ZIP_ENTRY_H
18 
19 #include "central_directory.h"
20 #include "zip_entry_data.h"
21 
22 namespace OHOS {
23 namespace SignatureTools {
24 class ZipEntry {
25 public:
ZipEntry()26     ZipEntry()
27     {
28         m_zipEntryData = nullptr;
29         m_fileEntryInCentralDirectory = nullptr;
30     }
31 
~ZipEntry()32     ~ZipEntry()
33     {
34         delete m_zipEntryData;
35         delete m_fileEntryInCentralDirectory;
36     }
37 
38     ZipEntryData* GetZipEntryData();
39 
40     void SetZipEntryData(ZipEntryData* zipEntryData);
41 
42     CentralDirectory* GetCentralDirectory();
43 
44     void SetCentralDirectory(CentralDirectory* centralDirectory);
45 
46     int Alignment(int alignNum);
47 
48 private:
49     bool CalZeroPaddingLengthForEntryExtra(uint16_t& padding);
50 
51     bool SetCenterDirectoryNewExtraLength(uint16_t newLength);
52 
53     bool SetEntryHeaderNewExtraLength(uint16_t newLength);
54 
55     bool GetAlignmentNewExtra(uint16_t newLength, const std::string& old, std::string& res);
56 
57     ZipEntryData* m_zipEntryData;
58 
59     CentralDirectory* m_fileEntryInCentralDirectory;
60 };
61 } // namespace SignatureTools
62 } // namespace OHOS
63 #endif // SIGNATRUETOOLS_ZIP_ENTRY_H