1 // OpenArchive.h
2 
3 #ifndef __OPEN_ARCHIVE_H
4 #define __OPEN_ARCHIVE_H
5 
6 #include "Common/MyString.h"
7 
8 #include "Windows/FileFind.h"
9 
10 #include "../../Archive/IArchive.h"
11 
12 #include "ArchiveOpenCallback.h"
13 #include "LoadCodecs.h"
14 
15 HRESULT GetArchiveItemBoolProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result);
16 HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result);
17 
18 struct CArc
19 {
20   CMyComPtr<IInArchive> Archive;
21   UString Path;
22   UString DefaultName;
23   int FormatIndex;
24   int SubfileIndex;
25   FILETIME MTime;
26   bool MTimeDefined;
27   UString ErrorMessage;
28 
CArcCArc29   CArc(): MTimeDefined(false) {}
30 
31   HRESULT GetItemPath(UInt32 index, UString &result) const;
32   HRESULT GetItemSize(UInt32 index, UInt64 &size, bool &defined) const;
33   HRESULT GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const;
IsItemAntiCArc34   HRESULT IsItemAnti(UInt32 index, bool &result) const
35     { return GetArchiveItemBoolProp(Archive, index, kpidIsAnti, result); }
36 
37   HRESULT OpenStream(
38     CCodecs *codecs,
39     int formatIndex,
40     IInStream *stream,
41     ISequentialInStream *seqStream,
42     IArchiveOpenCallback *callback);
43 
44   HRESULT OpenStreamOrFile(
45     CCodecs *codecs,
46     int formatIndex,
47     bool stdInMode,
48     IInStream *stream,
49     IArchiveOpenCallback *callback);
50 };
51 
52 struct CArchiveLink
53 {
54   CObjectVector<CArc> Arcs;
55   UStringVector VolumePaths;
56   UInt64 VolumesSize;
57   bool IsOpen;
58 
CArchiveLinkCArchiveLink59   CArchiveLink(): VolumesSize(0), IsOpen(false) {}
60   HRESULT Close();
61   void Release();
~CArchiveLinkCArchiveLink62   ~CArchiveLink() { Release(); }
63 
GetArchiveCArchiveLink64   IInArchive *GetArchive() const { return Arcs.Back().Archive; }
65 
66   HRESULT Open(
67     CCodecs *codecs,
68     const CIntVector &formatIndices,
69     bool stdInMode,
70     IInStream *stream,
71     const UString &filePath,
72     IArchiveOpenCallback *callback);
73 
74   HRESULT Open2(
75     CCodecs *codecs,
76     const CIntVector &formatIndices,
77     bool stdInMode,
78     IInStream *stream,
79     const UString &filePath,
80     IOpenCallbackUI *callbackUI);
81 
82   HRESULT ReOpen(
83     CCodecs *codecs,
84     const UString &filePath,
85     IArchiveOpenCallback *callback);
86 };
87 
88 #endif
89