Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | // OpenArchive.h |
michael@0 | 2 | |
michael@0 | 3 | #ifndef __OPENARCHIVE_H |
michael@0 | 4 | #define __OPENARCHIVE_H |
michael@0 | 5 | |
michael@0 | 6 | #include "Common/String.h" |
michael@0 | 7 | #include "Windows/FileFind.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "../../Archive/IArchive.h" |
michael@0 | 10 | #include "ArchiverInfo.h" |
michael@0 | 11 | #include "ArchiveOpenCallback.h" |
michael@0 | 12 | |
michael@0 | 13 | #ifndef EXCLUDE_COM |
michael@0 | 14 | #include "Windows/DLL.h" |
michael@0 | 15 | #endif |
michael@0 | 16 | |
michael@0 | 17 | HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, UString &result); |
michael@0 | 18 | HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &defaultName, UString &result); |
michael@0 | 19 | HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index, |
michael@0 | 20 | const FILETIME &defaultFileTime, FILETIME &fileTime); |
michael@0 | 21 | HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result); |
michael@0 | 22 | HRESULT IsArchiveItemAnti(IInArchive *archive, UInt32 index, bool &result); |
michael@0 | 23 | |
michael@0 | 24 | struct ISetSubArchiveName |
michael@0 | 25 | { |
michael@0 | 26 | virtual void SetSubArchiveName(const wchar_t *name) = 0; |
michael@0 | 27 | }; |
michael@0 | 28 | |
michael@0 | 29 | HRESULT OpenArchive( |
michael@0 | 30 | IInStream *inStream, |
michael@0 | 31 | const UString &fileName, |
michael@0 | 32 | #ifndef EXCLUDE_COM |
michael@0 | 33 | HMODULE *module, |
michael@0 | 34 | #endif |
michael@0 | 35 | IInArchive **archiveResult, |
michael@0 | 36 | CArchiverInfo &archiverInfoResult, |
michael@0 | 37 | UString &defaultItemName, |
michael@0 | 38 | IArchiveOpenCallback *openArchiveCallback); |
michael@0 | 39 | |
michael@0 | 40 | HRESULT OpenArchive(const UString &filePath, |
michael@0 | 41 | #ifndef EXCLUDE_COM |
michael@0 | 42 | HMODULE *module, |
michael@0 | 43 | #endif |
michael@0 | 44 | IInArchive **archive, |
michael@0 | 45 | CArchiverInfo &archiverInfo, |
michael@0 | 46 | UString &defaultItemName, |
michael@0 | 47 | IArchiveOpenCallback *openArchiveCallback); |
michael@0 | 48 | |
michael@0 | 49 | HRESULT OpenArchive(const UString &filePath, |
michael@0 | 50 | #ifndef EXCLUDE_COM |
michael@0 | 51 | HMODULE *module0, |
michael@0 | 52 | HMODULE *module1, |
michael@0 | 53 | #endif |
michael@0 | 54 | IInArchive **archive0, |
michael@0 | 55 | IInArchive **archive1, |
michael@0 | 56 | CArchiverInfo &archiverInfo0, |
michael@0 | 57 | CArchiverInfo &archiverInfo1, |
michael@0 | 58 | UString &defaultItemName0, |
michael@0 | 59 | UString &defaultItemName1, |
michael@0 | 60 | IArchiveOpenCallback *openArchiveCallback); |
michael@0 | 61 | |
michael@0 | 62 | |
michael@0 | 63 | HRESULT ReOpenArchive(IInArchive *archive, |
michael@0 | 64 | const UString &fileName); |
michael@0 | 65 | |
michael@0 | 66 | HRESULT MyOpenArchive(const UString &archiveName, |
michael@0 | 67 | #ifndef EXCLUDE_COM |
michael@0 | 68 | HMODULE *module, |
michael@0 | 69 | #endif |
michael@0 | 70 | IInArchive **archive, |
michael@0 | 71 | UString &defaultItemName, |
michael@0 | 72 | IOpenCallbackUI *openCallbackUI); |
michael@0 | 73 | |
michael@0 | 74 | HRESULT MyOpenArchive(const UString &archiveName, |
michael@0 | 75 | #ifndef EXCLUDE_COM |
michael@0 | 76 | HMODULE *module0, |
michael@0 | 77 | HMODULE *module1, |
michael@0 | 78 | #endif |
michael@0 | 79 | IInArchive **archive0, |
michael@0 | 80 | IInArchive **archive1, |
michael@0 | 81 | UString &defaultItemName0, |
michael@0 | 82 | UString &defaultItemName1, |
michael@0 | 83 | UStringVector &volumePaths, |
michael@0 | 84 | IOpenCallbackUI *openCallbackUI); |
michael@0 | 85 | |
michael@0 | 86 | struct CArchiveLink |
michael@0 | 87 | { |
michael@0 | 88 | #ifndef EXCLUDE_COM |
michael@0 | 89 | NWindows::NDLL::CLibrary Library0; |
michael@0 | 90 | NWindows::NDLL::CLibrary Library1; |
michael@0 | 91 | #endif |
michael@0 | 92 | CMyComPtr<IInArchive> Archive0; |
michael@0 | 93 | CMyComPtr<IInArchive> Archive1; |
michael@0 | 94 | UString DefaultItemName0; |
michael@0 | 95 | UString DefaultItemName1; |
michael@0 | 96 | |
michael@0 | 97 | CArchiverInfo ArchiverInfo0; |
michael@0 | 98 | CArchiverInfo ArchiverInfo1; |
michael@0 | 99 | |
michael@0 | 100 | UStringVector VolumePaths; |
michael@0 | 101 | |
michael@0 | 102 | int GetNumLevels() const |
michael@0 | 103 | { |
michael@0 | 104 | int result = 0; |
michael@0 | 105 | if (Archive0) |
michael@0 | 106 | { |
michael@0 | 107 | result++; |
michael@0 | 108 | if (Archive1) |
michael@0 | 109 | result++; |
michael@0 | 110 | } |
michael@0 | 111 | return result; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | |
michael@0 | 115 | IInArchive *GetArchive() { return Archive1 != 0 ? Archive1: Archive0; } |
michael@0 | 116 | UString GetDefaultItemName() { return Archive1 != 0 ? DefaultItemName1: DefaultItemName0; } |
michael@0 | 117 | const CArchiverInfo &GetArchiverInfo() { return Archive1 != 0 ? ArchiverInfo1: ArchiverInfo0; } |
michael@0 | 118 | HRESULT Close(); |
michael@0 | 119 | void Release(); |
michael@0 | 120 | }; |
michael@0 | 121 | |
michael@0 | 122 | HRESULT OpenArchive(const UString &archiveName, |
michael@0 | 123 | CArchiveLink &archiveLink, |
michael@0 | 124 | IArchiveOpenCallback *openCallback); |
michael@0 | 125 | |
michael@0 | 126 | HRESULT MyOpenArchive(const UString &archiveName, |
michael@0 | 127 | CArchiveLink &archiveLink, |
michael@0 | 128 | IOpenCallbackUI *openCallbackUI); |
michael@0 | 129 | |
michael@0 | 130 | HRESULT ReOpenArchive(CArchiveLink &archiveLink, |
michael@0 | 131 | const UString &fileName); |
michael@0 | 132 | |
michael@0 | 133 | #endif |
michael@0 | 134 |