other-licenses/7zstub/src/7zip/Bundles/SFXSetup-moz/ExtractCallback.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 // ExtractCallback.h
     3 #ifndef __EXTRACTCALLBACK_H
     4 #define __EXTRACTCALLBACK_H
     6 #include "resource.h"
     8 #include "Common/String.h"
     9 #include "Windows/ResourceString.h"
    11 #include "../../Archive/IArchive.h"
    13 #include "../../Common/FileStreams.h"
    14 #include "../../ICoder.h"
    16 #ifndef _NO_PROGRESS
    17 #include "../../FileManager/Resource/ProgressDialog/ProgressDialog.h"
    18 #endif
    20 class CExtractCallbackImp: 
    21   public IArchiveExtractCallback,
    22   public CMyUnknownImp
    23 {
    24 public:
    26   MY_UNKNOWN_IMP
    28   // IProgress
    29   STDMETHOD(SetTotal)(UInt64 size);
    30   STDMETHOD(SetCompleted)(const UInt64 *completeValue);
    32   // IExtractCallback
    33   STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, 
    34       Int32 askExtractMode);
    35   STDMETHOD(PrepareOperation)(Int32 askExtractMode);
    36   STDMETHOD(SetOperationResult)(Int32 resultEOperationResult);
    38 private:
    39   CMyComPtr<IInArchive> _archiveHandler;
    40   UString _directoryPath;
    42   UString _filePath;
    44   UString _diskFilePath;
    46   bool _extractMode;
    47   struct CProcessedFileInfo
    48   {
    49     FILETIME UTCLastWriteTime;
    50     bool IsDirectory;
    51     UInt32 Attributes;
    52   } _processedFileInfo;
    54   COutFileStream *_outFileStreamSpec;
    55   CMyComPtr<ISequentialOutStream> _outFileStream;
    57   UString _itemDefaultName;
    58   FILETIME _utcLastWriteTimeDefault;
    59   UInt32 _attributesDefault;
    61   void CreateComplexDirectory(const UStringVector &dirPathParts);
    62 public:
    63   #ifndef _NO_PROGRESS
    64   CProgressDialog ProgressDialog;
    65   #endif
    67   bool _isCorrupt;
    68   UString _message;
    70   void Init(IInArchive *archiveHandler,     
    71     const UString &directoryPath, 
    72     const UString &itemDefaultName,
    73     const FILETIME &utcLastWriteTimeDefault,
    74     UInt32 attributesDefault);
    76   #ifndef _NO_PROGRESS
    77   HRESULT StartProgressDialog(const UString &title)
    78   {
    79     ProgressDialog.Create(title, 0);
    80     {
    81       #ifdef LANG        
    82       ProgressDialog.SetText(LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890));
    83       #else
    84       ProgressDialog.SetText(NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING));
    85       #endif
    86     }
    88     ProgressDialog.Show(SW_SHOWNORMAL);    
    89     return S_OK;
    90   }
    91   virtual ~CExtractCallbackImp() { ProgressDialog.Destroy(); }
    92   #endif
    94 };
    96 #endif

mercurial