Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: third_party/lzma/v4_65/files/CPP/7zip/UI/Common/LoadCodecs.h

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // LoadCodecs.h
2
3 #ifndef __LOADCODECS_H
4 #define __LOADCODECS_H
5
6 #include "../../../Common/Types.h"
7 #include "../../../Common/MyCom.h"
8 #include "../../../Common/MyString.h"
9 #include "../../../Common/Buffer.h"
10 #include "../../ICoder.h"
11
12 #ifdef EXTERNAL_CODECS
13 #include "../../../Windows/DLL.h"
14 #endif
15
16 struct CDllCodecInfo
17 {
18 CLSID Encoder;
19 CLSID Decoder;
20 bool EncoderIsAssigned;
21 bool DecoderIsAssigned;
22 int LibIndex;
23 UInt32 CodecIndex;
24 };
25
26 #include "../../Archive/IArchive.h"
27
28 typedef IInArchive * (*CreateInArchiveP)();
29 typedef IOutArchive * (*CreateOutArchiveP)();
30
31 struct CArcExtInfo
32 {
33 UString Ext;
34 UString AddExt;
35 CArcExtInfo() {}
36 CArcExtInfo(const UString &ext): Ext(ext) {}
37 CArcExtInfo(const UString &ext, const UString &addExt): Ext(ext), AddExt(addEx t) {}
38 };
39
40
41 struct CArcInfoEx
42 {
43 #ifdef EXTERNAL_CODECS
44 int LibIndex;
45 UInt32 FormatIndex;
46 CLSID ClassID;
47 #endif
48 bool UpdateEnabled;
49 CreateInArchiveP CreateInArchive;
50 CreateOutArchiveP CreateOutArchive;
51 UString Name;
52 CObjectVector<CArcExtInfo> Exts;
53 #ifndef _SFX
54 CByteBuffer StartSignature;
55 // CByteBuffer FinishSignature;
56 #ifdef NEW_FOLDER_INTERFACE
57 UStringVector AssociateExts;
58 #endif
59 #endif
60 bool KeepName;
61 UString GetMainExt() const
62 {
63 if (Exts.IsEmpty())
64 return UString();
65 return Exts[0].Ext;
66 }
67 int FindExtension(const UString &ext) const
68 {
69 for (int i = 0; i < Exts.Size(); i++)
70 if (ext.CompareNoCase(Exts[i].Ext) == 0)
71 return i;
72 return -1;
73 }
74 UString GetAllExtensions() const
75 {
76 UString s;
77 for (int i = 0; i < Exts.Size(); i++)
78 {
79 if (i > 0)
80 s += ' ';
81 s += Exts[i].Ext;
82 }
83 return s;
84 }
85
86 void AddExts(const wchar_t* ext, const wchar_t* addExt);
87
88 CArcInfoEx():
89 #ifdef EXTERNAL_CODECS
90 LibIndex(-1),
91 #endif
92 UpdateEnabled(false),
93 CreateInArchive(0), CreateOutArchive(0),
94 KeepName(false)
95 #ifndef _SFX
96 #endif
97 {}
98 };
99
100 #ifdef EXTERNAL_CODECS
101 typedef UInt32 (WINAPI *GetMethodPropertyFunc)(UInt32 index, PROPID propID, PROP VARIANT *value);
102 typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *interfa ceID, void **outObject);
103
104
105 struct CCodecLib
106 {
107 NWindows::NDLL::CLibrary Lib;
108 GetMethodPropertyFunc GetMethodProperty;
109 CreateObjectFunc CreateObject;
110 #ifdef NEW_FOLDER_INTERFACE
111 struct CIconPair
112 {
113 UString Ext;
114 UInt32 IconIndex;
115 };
116 CSysString Path;
117 CObjectVector<CIconPair> IconPairs;
118 void LoadIcons();
119 int FindIconIndex(const UString &ext) const;
120 #endif
121 CCodecLib(): GetMethodProperty(0) {}
122 };
123 #endif
124
125 class CCodecs:
126 #ifdef EXTERNAL_CODECS
127 public ICompressCodecsInfo,
128 #else
129 public IUnknown,
130 #endif
131 public CMyUnknownImp
132 {
133 public:
134 #ifdef EXTERNAL_CODECS
135 CObjectVector<CCodecLib> Libs;
136 CObjectVector<CDllCodecInfo> Codecs;
137 HRESULT LoadCodecs();
138 HRESULT LoadFormats();
139 HRESULT LoadDll(const CSysString &path);
140 HRESULT LoadDllsFromFolder(const CSysString &folderPrefix);
141
142 HRESULT CreateArchiveHandler(const CArcInfoEx &ai, void **archive, bool outHan dler) const
143 {
144 return Libs[ai.LibIndex].CreateObject(&ai.ClassID, outHandler ? &IID_IOutArc hive : &IID_IInArchive, (void **)archive);
145 }
146 #endif
147
148 public:
149 CObjectVector<CArcInfoEx> Formats;
150 HRESULT Load();
151
152 #ifndef _SFX
153 int FindFormatForArchiveName(const UString &arcPath) const;
154 int FindFormatForExtension(const UString &ext) const;
155 int FindFormatForArchiveType(const UString &arcType) const;
156 bool FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndice s) const;
157 #endif
158
159 MY_UNKNOWN_IMP
160
161 #ifdef EXTERNAL_CODECS
162 STDMETHOD(GetNumberOfMethods)(UInt32 *numMethods);
163 STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
164 STDMETHOD(CreateDecoder)(UInt32 index, const GUID *interfaceID, void **coder);
165 STDMETHOD(CreateEncoder)(UInt32 index, const GUID *interfaceID, void **coder);
166 #endif
167
168 int GetCodecLibIndex(UInt32 index);
169 bool GetCodecEncoderIsAssigned(UInt32 index);
170 HRESULT GetCodecId(UInt32 index, UInt64 &id);
171 UString GetCodecName(UInt32 index);
172
173 HRESULT CreateInArchive(int formatIndex, CMyComPtr<IInArchive> &archive) const
174 {
175 const CArcInfoEx &ai = Formats[formatIndex];
176 #ifdef EXTERNAL_CODECS
177 if (ai.LibIndex < 0)
178 #endif
179 {
180 archive = ai.CreateInArchive();
181 return S_OK;
182 }
183 #ifdef EXTERNAL_CODECS
184 return CreateArchiveHandler(ai, (void **)&archive, false);
185 #endif
186 }
187 HRESULT CreateOutArchive(int formatIndex, CMyComPtr<IOutArchive> &archive) con st
188 {
189 const CArcInfoEx &ai = Formats[formatIndex];
190 #ifdef EXTERNAL_CODECS
191 if (ai.LibIndex < 0)
192 #endif
193 {
194 archive = ai.CreateOutArchive();
195 return S_OK;
196 }
197 #ifdef EXTERNAL_CODECS
198 return CreateArchiveHandler(ai, (void **)&archive, true);
199 #endif
200 }
201 int FindOutFormatFromName(const UString &name) const
202 {
203 for (int i = 0; i < Formats.Size(); i++)
204 {
205 const CArcInfoEx &arc = Formats[i];
206 if (!arc.UpdateEnabled)
207 continue;
208 if (arc.Name.CompareNoCase(name) == 0)
209 return i;
210 }
211 return -1;
212 }
213
214 #ifdef EXTERNAL_CODECS
215 HRESULT CreateCoder(const UString &name, bool encode, CMyComPtr<ICompressCoder > &coder) const;
216 #endif
217
218 };
219
220 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698