misc/libphysfs/lzma/CPP/7zip/UI/Common/Update.h
branchui-scaling
changeset 15283 c4fd2813b127
parent 13390 0135e64c6c66
parent 15279 7ab5cf405686
child 15663 d92eeb468dad
equal deleted inserted replaced
13390:0135e64c6c66 15283:c4fd2813b127
     1 // Update.h
       
     2 
       
     3 #ifndef __UPDATE_H
       
     4 #define __UPDATE_H
       
     5 
       
     6 #include "Common/Wildcard.h"
       
     7 #include "Windows/FileFind.h"
       
     8 #include "../../Archive/IArchive.h"
       
     9 
       
    10 #include "UpdateAction.h"
       
    11 #include "ArchiveOpenCallback.h"
       
    12 #include "UpdateCallback.h"
       
    13 #include "Property.h"
       
    14 #include "LoadCodecs.h"
       
    15 
       
    16 struct CArchivePath
       
    17 {
       
    18   UString Prefix;   // path(folder) prefix including slash
       
    19   UString Name; // base name
       
    20   UString BaseExtension; // archive type extension or "exe" extension 
       
    21   UString VolExtension;  // archive type extension for volumes
       
    22 
       
    23   bool Temp;
       
    24   UString TempPrefix;  // path(folder) for temp location
       
    25   UString TempPostfix;
       
    26 
       
    27   CArchivePath(): Temp(false) {};
       
    28   
       
    29   void ParseFromPath(const UString &path)
       
    30   {
       
    31     SplitPathToParts(path, Prefix, Name);
       
    32     if (Name.IsEmpty())
       
    33       return;
       
    34     int dotPos = Name.ReverseFind(L'.');
       
    35     if (dotPos <= 0)
       
    36       return;
       
    37     if (dotPos == Name.Length() - 1)
       
    38     {
       
    39       Name = Name.Left(dotPos);
       
    40       BaseExtension.Empty();
       
    41       return;
       
    42     }
       
    43     if (BaseExtension.CompareNoCase(Name.Mid(dotPos + 1)) == 0)
       
    44     {
       
    45       BaseExtension = Name.Mid(dotPos + 1);
       
    46       Name = Name.Left(dotPos);
       
    47     }
       
    48     else
       
    49       BaseExtension.Empty();
       
    50   }
       
    51 
       
    52   UString GetPathWithoutExt() const
       
    53   {
       
    54     return Prefix + Name;
       
    55   }
       
    56 
       
    57   UString GetFinalPath() const
       
    58   {
       
    59     UString path = GetPathWithoutExt();
       
    60     if (!BaseExtension.IsEmpty())
       
    61       path += UString(L'.') + BaseExtension;
       
    62     return path;
       
    63   }
       
    64 
       
    65   
       
    66   UString GetTempPath() const
       
    67   {
       
    68     UString path = TempPrefix + Name;
       
    69     if (!BaseExtension.IsEmpty())
       
    70       path += UString(L'.') + BaseExtension;
       
    71     path += L".tmp";
       
    72     path += TempPostfix;
       
    73     return path; 
       
    74   }
       
    75 };
       
    76 
       
    77 struct CUpdateArchiveCommand
       
    78 {
       
    79   UString UserArchivePath;
       
    80   CArchivePath ArchivePath;
       
    81   NUpdateArchive::CActionSet ActionSet;
       
    82 };
       
    83 
       
    84 struct CCompressionMethodMode
       
    85 {
       
    86   int FormatIndex;
       
    87   CObjectVector<CProperty> Properties;
       
    88   CCompressionMethodMode(): FormatIndex(-1) {}
       
    89 };
       
    90 
       
    91 struct CUpdateOptions
       
    92 {
       
    93   CCompressionMethodMode MethodMode;
       
    94 
       
    95   CObjectVector<CUpdateArchiveCommand> Commands;
       
    96   bool UpdateArchiveItself;
       
    97   CArchivePath ArchivePath;
       
    98   
       
    99   bool SfxMode;
       
   100   UString SfxModule;
       
   101   
       
   102   bool OpenShareForWrite;
       
   103 
       
   104   bool StdInMode;
       
   105   UString StdInFileName;
       
   106   bool StdOutMode;
       
   107   
       
   108   bool EMailMode;
       
   109   bool EMailRemoveAfter;
       
   110   UString EMailAddress;
       
   111 
       
   112   UString WorkingDir;
       
   113 
       
   114   bool Init(const CCodecs *codecs, const UString &arcPath, const UString &arcType);
       
   115 
       
   116   CUpdateOptions():
       
   117     UpdateArchiveItself(true),
       
   118     SfxMode(false),
       
   119     StdInMode(false),
       
   120     StdOutMode(false),
       
   121     EMailMode(false),
       
   122     EMailRemoveAfter(false),
       
   123     OpenShareForWrite(false)
       
   124       {};
       
   125   CRecordVector<UInt64> VolumesSizes;
       
   126 };
       
   127 
       
   128 struct CErrorInfo
       
   129 {
       
   130   DWORD SystemError;
       
   131   UString FileName;
       
   132   UString FileName2;
       
   133   UString Message;
       
   134   // UStringVector ErrorPaths;
       
   135   // CRecordVector<DWORD> ErrorCodes;
       
   136   CErrorInfo(): SystemError(0) {};
       
   137 };
       
   138 
       
   139 struct CUpdateErrorInfo: public CErrorInfo
       
   140 {
       
   141 };
       
   142 
       
   143 #define INTERFACE_IUpdateCallbackUI2(x) \
       
   144   INTERFACE_IUpdateCallbackUI(x) \
       
   145   virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) x; \
       
   146   virtual HRESULT StartScanning() x; \
       
   147   virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) x; \
       
   148   virtual HRESULT FinishScanning() x; \
       
   149   virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \
       
   150   virtual HRESULT FinishArchive() x; \
       
   151 
       
   152 struct IUpdateCallbackUI2: public IUpdateCallbackUI
       
   153 {
       
   154   INTERFACE_IUpdateCallbackUI2(=0)
       
   155 };
       
   156 
       
   157 HRESULT UpdateArchive(
       
   158     CCodecs *codecs,
       
   159     const NWildcard::CCensor &censor, 
       
   160     CUpdateOptions &options,
       
   161     CUpdateErrorInfo &errorInfo,
       
   162     IOpenCallbackUI *openCallback,
       
   163     IUpdateCallbackUI2 *callback);
       
   164 
       
   165 #endif