michael@0: // ArchiveOpenCallback.h michael@0: michael@0: #ifndef __ARCHIVE_OPEN_CALLBACK_H michael@0: #define __ARCHIVE_OPEN_CALLBACK_H michael@0: michael@0: #include "Common/String.h" michael@0: #include "Common/MyCom.h" michael@0: #include "Windows/FileFind.h" michael@0: michael@0: #ifndef _NO_CRYPTO michael@0: #include "../../IPassword.h" michael@0: #endif michael@0: #include "../../Archive/IArchive.h" michael@0: michael@0: struct IOpenCallbackUI michael@0: { michael@0: virtual HRESULT CheckBreak() = 0; michael@0: virtual HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes) = 0; michael@0: virtual HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes) = 0; michael@0: #ifndef _NO_CRYPTO michael@0: virtual HRESULT CryptoGetTextPassword(BSTR *password) = 0; michael@0: virtual HRESULT GetPasswordIfAny(UString &password) = 0; michael@0: #endif michael@0: }; michael@0: michael@0: class COpenCallbackImp: michael@0: public IArchiveOpenCallback, michael@0: public IArchiveOpenVolumeCallback, michael@0: public IArchiveOpenSetSubArchiveName, michael@0: #ifndef _NO_CRYPTO michael@0: public ICryptoGetTextPassword, michael@0: #endif michael@0: public CMyUnknownImp michael@0: { michael@0: public: michael@0: #ifndef _NO_CRYPTO michael@0: MY_UNKNOWN_IMP3( michael@0: IArchiveOpenVolumeCallback, michael@0: ICryptoGetTextPassword, michael@0: IArchiveOpenSetSubArchiveName michael@0: ) michael@0: #else michael@0: MY_UNKNOWN_IMP2( michael@0: IArchiveOpenVolumeCallback, michael@0: IArchiveOpenSetSubArchiveName michael@0: ) michael@0: #endif michael@0: michael@0: STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes); michael@0: STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes); michael@0: michael@0: // IArchiveOpenVolumeCallback michael@0: STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value); michael@0: STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream); michael@0: michael@0: #ifndef _NO_CRYPTO michael@0: // ICryptoGetTextPassword michael@0: STDMETHOD(CryptoGetTextPassword)(BSTR *password); michael@0: #endif michael@0: michael@0: STDMETHOD(SetSubArchiveName(const wchar_t *name)) michael@0: { michael@0: _subArchiveMode = true; michael@0: _subArchiveName = name; michael@0: return S_OK; michael@0: } michael@0: michael@0: private: michael@0: UString _folderPrefix; michael@0: NWindows::NFile::NFind::CFileInfoW _fileInfo; michael@0: bool _subArchiveMode; michael@0: UString _subArchiveName; michael@0: public: michael@0: UStringVector FileNames; michael@0: IOpenCallbackUI *Callback; michael@0: void Init(const UString &folderPrefix, const UString &fileName) michael@0: { michael@0: _folderPrefix = folderPrefix; michael@0: if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo)) michael@0: throw 1; michael@0: FileNames.Clear(); michael@0: _subArchiveMode = false; michael@0: } michael@0: int FindName(const UString &name); michael@0: }; michael@0: michael@0: #endif