• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // HandlerOut.h
2 
3 #ifndef ZIP7_INC_HANDLER_OUT_H
4 #define ZIP7_INC_HANDLER_OUT_H
5 
6 #include "../../../Windows/System.h"
7 
8 #include "../../Common/MethodProps.h"
9 
10 namespace NArchive {
11 
12 bool ParseSizeString(const wchar_t *name, const PROPVARIANT &prop, UInt64 percentsBase, UInt64 &res);
13 
14 class CCommonMethodProps
15 {
16 protected:
InitCommon()17   void InitCommon()
18   {
19     // _Write_MTime = true;
20     #ifndef Z7_ST
21     _numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors();
22     _numThreads_WasForced = false;
23     #endif
24 
25     UInt64 memAvail = (UInt64)(sizeof(size_t)) << 28;
26     _memAvail = memAvail;
27     _memUsage_Compress = memAvail;
28     _memUsage_Decompress = memAvail;
29     _memUsage_WasSet = NWindows::NSystem::GetRamSize(memAvail);
30     if (_memUsage_WasSet)
31     {
32       _memAvail = memAvail;
33       unsigned bits = sizeof(size_t) * 8;
34       if (bits == 32)
35       {
36         const UInt32 limit2 = (UInt32)7 << 28;
37         if (memAvail > limit2)
38           memAvail = limit2;
39       }
40       // 80% - is auto usage limit in handlers
41       // _memUsage_Compress = memAvail * 4 / 5;
42       // _memUsage_Compress = Calc_From_Val_Percents(memAvail, 80);
43       _memUsage_Compress = Calc_From_Val_Percents_Less100(memAvail, 80);
44       _memUsage_Decompress = memAvail / 32 * 17;
45     }
46   }
47 
48 public:
49   #ifndef Z7_ST
50   UInt32 _numThreads;
51   UInt32 _numProcessors;
52   bool _numThreads_WasForced;
53   #endif
54 
55   bool _memUsage_WasSet;
56   UInt64 _memUsage_Compress;
57   UInt64 _memUsage_Decompress;
58   UInt64 _memAvail;
59 
60   bool SetCommonProperty(const UString &name, const PROPVARIANT &value, HRESULT &hres);
61 
CCommonMethodProps()62   CCommonMethodProps() { InitCommon(); }
63 };
64 
65 
66 #ifndef Z7_EXTRACT_ONLY
67 
68 class CMultiMethodProps: public CCommonMethodProps
69 {
70   UInt32 _level;
71   int _analysisLevel;
72 
73   void InitMulti();
74 public:
75   UInt32 _crcSize;
76   CObjectVector<COneMethodInfo> _methods;
77   COneMethodInfo _filterMethod;
78   bool _autoFilter;
79 
80 
81   void SetGlobalLevelTo(COneMethodInfo &oneMethodInfo) const;
82 
83   #ifndef Z7_ST
84   static void SetMethodThreadsTo_IfNotFinded(CMethodProps &props, UInt32 numThreads);
85   static void SetMethodThreadsTo_Replace(CMethodProps &props, UInt32 numThreads);
86   #endif
87 
88 
GetNumEmptyMethods()89   unsigned GetNumEmptyMethods() const
90   {
91     unsigned i;
92     for (i = 0; i < _methods.Size(); i++)
93       if (!_methods[i].IsEmpty())
94         break;
95     return i;
96   }
97 
GetLevel()98   int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
GetAnalysisLevel()99   int GetAnalysisLevel() const { return _analysisLevel; }
100 
101   void Init();
CMultiMethodProps()102   CMultiMethodProps() { InitMulti(); }
103 
104   HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &value);
105 };
106 
107 
108 class CSingleMethodProps: public COneMethodInfo, public CCommonMethodProps
109 {
110   UInt32 _level;
111 
InitSingle()112   void InitSingle()
113   {
114     _level = (UInt32)(Int32)-1;
115   }
116 
117 public:
118   void Init();
CSingleMethodProps()119   CSingleMethodProps() { InitSingle(); }
120 
GetLevel()121   int GetLevel() const { return _level == (UInt32)(Int32)-1 ? 5 : (int)_level; }
122   HRESULT SetProperty(const wchar_t *name, const PROPVARIANT &values);
123   HRESULT SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
124 };
125 
126 #endif
127 
128 struct CHandlerTimeOptions
129 {
130   CBoolPair Write_MTime;
131   CBoolPair Write_ATime;
132   CBoolPair Write_CTime;
133   UInt32 Prec;
134 
InitCHandlerTimeOptions135   void Init()
136   {
137     Write_MTime.Init();
138     Write_MTime.Val = true;
139     Write_ATime.Init();
140     Write_CTime.Init();
141     Prec = (UInt32)(Int32)-1;
142   }
143 
CHandlerTimeOptionsCHandlerTimeOptions144   CHandlerTimeOptions()
145   {
146     Init();
147   }
148 
149   HRESULT Parse(const UString &name, const PROPVARIANT &prop, bool &processed);
150 };
151 
152 }
153 
154 #endif
155