xref: /aosp_15_r20/external/lzma/CPP/7zip/Bundles/SFXSetup/ExtractCallbackSfx.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // ExtractCallbackSfx.h
2 
3 #ifndef ZIP7_INC_EXTRACT_CALLBACK_SFX_H
4 #define ZIP7_INC_EXTRACT_CALLBACK_SFX_H
5 
6 #include "resource.h"
7 
8 #include "../../../Windows/ResourceString.h"
9 
10 #include "../../Archive/IArchive.h"
11 
12 #include "../../Common/FileStreams.h"
13 #include "../../ICoder.h"
14 
15 #include "../../UI/FileManager/LangUtils.h"
16 
17 #ifndef _NO_PROGRESS
18 #include "../../UI/FileManager/ProgressDialog.h"
19 #endif
20 #include "../../UI/Common/ArchiveOpenCallback.h"
21 
22 class CExtractCallbackImp Z7_final:
23   public IArchiveExtractCallback,
24   public IOpenCallbackUI,
25   public CMyUnknownImp
26 {
27   Z7_COM_UNKNOWN_IMP_0
28   Z7_IFACE_COM7_IMP(IProgress)
29   Z7_IFACE_COM7_IMP(IArchiveExtractCallback)
30   Z7_IFACE_IMP(IOpenCallbackUI)
31 
32   CMyComPtr<IInArchive> _archiveHandler;
33   FString _directoryPath;
34   UString _filePath;
35   FString _diskFilePath;
36 
37   bool _extractMode;
38   struct CProcessedFileInfo
39   {
40     FILETIME MTime;
41     bool IsDir;
42     UInt32 Attributes;
43   } _processedFileInfo;
44 
45   COutFileStream *_outFileStreamSpec;
46   CMyComPtr<ISequentialOutStream> _outFileStream;
47 
48   UString _itemDefaultName;
49   FILETIME _defaultMTime;
50   UInt32 _defaultAttributes;
51 
52   void CreateComplexDirectory(const UStringVector &dirPathParts);
53 public:
54   #ifndef _NO_PROGRESS
55   CProgressDialog ProgressDialog;
56   #endif
57 
58   bool _isCorrupt;
59   UString _message;
60 
61   void Init(IInArchive *archiveHandler,
62     const FString &directoryPath,
63     const UString &itemDefaultName,
64     const FILETIME &defaultMTime,
65     UInt32 defaultAttributes);
66 
67   #ifndef _NO_PROGRESS
StartProgressDialog(const UString & title,NWindows::CThread & thread)68   HRESULT StartProgressDialog(const UString &title, NWindows::CThread &thread)
69   {
70     ProgressDialog.Create(title, thread, NULL);
71     {
72       ProgressDialog.SetText(LangString(IDS_PROGRESS_EXTRACTING));
73     }
74 
75     ProgressDialog.Show(SW_SHOWNORMAL);
76     return S_OK;
77   }
~CExtractCallbackImp()78   ~CExtractCallbackImp() { ProgressDialog.Destroy(); }
79   #endif
80 
81 };
82 
83 #endif
84