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