xref: /aosp_15_r20/external/lzma/CPP/7zip/Archive/7z/7zUpdate.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // 7zUpdate.h
2 
3 #ifndef ZIP7_INC_7Z_UPDATE_H
4 #define ZIP7_INC_7Z_UPDATE_H
5 
6 #include "../IArchive.h"
7 
8 // #include "../../Common/UniqBlocks.h"
9 
10 #include "7zCompressionMode.h"
11 #include "7zIn.h"
12 
13 namespace NArchive {
14 namespace N7z {
15 
16 /*
17 struct CTreeFolder
18 {
19   UString Name;
20   int Parent;
21   CIntVector SubFolders;
22   int UpdateItemIndex;
23   int SortIndex;
24   int SortIndexEnd;
25 
26   CTreeFolder(): UpdateItemIndex(-1) {}
27 };
28 */
29 
30 struct CUpdateItem
31 {
32   int IndexInArchive;
33   unsigned IndexInClient;
34 
35   UInt64 CTime;
36   UInt64 ATime;
37   UInt64 MTime;
38 
39   UInt64 Size;
40   UString Name;
41   /*
42   bool IsAltStream;
43   int ParentFolderIndex;
44   int TreeFolderIndex;
45   */
46 
47   // that code is not used in 9.26
48   // int ParentSortIndex;
49   // int ParentSortIndexEnd;
50 
51   UInt32 Attrib;
52 
53   bool NewData;
54   bool NewProps;
55 
56   bool IsAnti;
57   bool IsDir;
58 
59   bool AttribDefined;
60   bool CTimeDefined;
61   bool ATimeDefined;
62   bool MTimeDefined;
63 
64   // bool ATime_WasReadByAnalysis;
65 
66   // int SecureIndex; // 0 means (no_security)
67 
HasStreamCUpdateItem68   bool HasStream() const { return !IsDir && !IsAnti && Size != 0; }
69   // bool HasStream() const { return !IsDir && !IsAnti /* && Size != 0 */; } // for test purposes
70 
CUpdateItemCUpdateItem71   CUpdateItem():
72       // ParentSortIndex(-1),
73       // IsAltStream(false),
74       IsAnti(false),
75       IsDir(false),
76       AttribDefined(false),
77       CTimeDefined(false),
78       ATimeDefined(false),
79       MTimeDefined(false)
80       // , ATime_WasReadByAnalysis(false)
81       // SecureIndex(0)
82       {}
SetDirStatusFromAttribCUpdateItem83   void SetDirStatusFromAttrib() { IsDir = ((Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0); }
84 
85   // unsigned GetExtensionPos() const;
86   // UString GetExtension() const;
87 };
88 
89 struct CUpdateOptions
90 {
91   const CCompressionMethodMode *Method;
92   const CCompressionMethodMode *HeaderMethod;
93   bool UseFilters; // use additional filters for some files
94   bool MaxFilter;  // use BCJ2 filter instead of BCJ
95   int AnalysisLevel;
96 
97   UInt64 NumSolidFiles;
98   UInt64 NumSolidBytes;
99   bool SolidExtension;
100 
101   bool UseTypeSorting;
102 
103   bool RemoveSfxBlock;
104   bool MultiThreadMixer;
105 
106   bool Need_CTime;
107   bool Need_ATime;
108   bool Need_MTime;
109   bool Need_Attrib;
110   // bool Need_Crc;
111 
112   CHeaderOptions HeaderOptions;
113 
114   CUIntVector DisabledFilterIDs;
115 
Add_DisabledFilter_for_idCUpdateOptions116   void Add_DisabledFilter_for_id(UInt32 id,
117       const CUIntVector &enabledFilters)
118   {
119     if (enabledFilters.FindInSorted(id) < 0)
120       DisabledFilterIDs.AddToUniqueSorted(id);
121   }
122 
SetFilterSupporting_ver_enabled_disabledCUpdateOptions123   void SetFilterSupporting_ver_enabled_disabled(
124       UInt32 compatVer,
125       const CUIntVector &enabledFilters,
126       const CUIntVector &disabledFilters)
127   {
128     DisabledFilterIDs = disabledFilters;
129     if (compatVer < 2300) Add_DisabledFilter_for_id(k_ARM64, enabledFilters);
130     if (compatVer < 2402) Add_DisabledFilter_for_id(k_RISCV, enabledFilters);
131   }
132 
CUpdateOptionsCUpdateOptions133   CUpdateOptions():
134       Method(NULL),
135       HeaderMethod(NULL),
136       UseFilters(false),
137       MaxFilter(false),
138       AnalysisLevel(-1),
139       NumSolidFiles((UInt64)(Int64)(-1)),
140       NumSolidBytes((UInt64)(Int64)(-1)),
141       SolidExtension(false),
142       UseTypeSorting(true),
143       RemoveSfxBlock(false),
144       MultiThreadMixer(true),
145       Need_CTime(false),
146       Need_ATime(false),
147       Need_MTime(false),
148       Need_Attrib(false)
149       // , Need_Crc(true)
150   {
151     DisabledFilterIDs.Add(k_RISCV);
152   }
153 };
154 
155 HRESULT Update(
156     DECL_EXTERNAL_CODECS_LOC_VARS
157     IInStream *inStream,
158     const CDbEx *db,
159     CObjectVector<CUpdateItem> &updateItems,
160     // const CObjectVector<CTreeFolder> &treeFolders, // treeFolders[0] is root
161     // const CUniqBlocks &secureBlocks,
162     ISequentialOutStream *seqOutStream,
163     IArchiveUpdateCallback *updateCallback,
164     const CUpdateOptions &options);
165 }}
166 
167 #endif
168