misc/libphysfs/lzma/CPP/7zip/Archive/IArchive.h
changeset 13881 99b265e0d1d0
parent 13880 5f819b90d479
child 13882 b172a5d40eee
equal deleted inserted replaced
13880:5f819b90d479 13881:99b265e0d1d0
     1 // IArchive.h
       
     2 
       
     3 #ifndef __IARCHIVE_H
       
     4 #define __IARCHIVE_H
       
     5 
       
     6 #include "../IStream.h"
       
     7 #include "../IProgress.h"
       
     8 #include "../PropID.h"
       
     9 
       
    10 #define ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 6, x)
       
    11 #define ARCHIVE_INTERFACE(i, x) ARCHIVE_INTERFACE_SUB(i, IUnknown, x)
       
    12 
       
    13 namespace NFileTimeType
       
    14 {
       
    15   enum EEnum
       
    16   {
       
    17     kWindows,
       
    18     kUnix,
       
    19     kDOS
       
    20   };
       
    21 }
       
    22 
       
    23 namespace NArchive
       
    24 {
       
    25   enum 
       
    26   {
       
    27     kName = 0,
       
    28     kClassID,
       
    29     kExtension,
       
    30     kAddExtension,
       
    31     kUpdate,
       
    32     kKeepName,
       
    33     kStartSignature,
       
    34     kFinishSignature,
       
    35     kAssociate
       
    36   };
       
    37 
       
    38   namespace NExtract
       
    39   {
       
    40     namespace NAskMode
       
    41     {
       
    42       enum 
       
    43       {
       
    44         kExtract = 0,
       
    45         kTest,
       
    46         kSkip
       
    47       };
       
    48     }
       
    49     namespace NOperationResult
       
    50     {
       
    51       enum 
       
    52       {
       
    53         kOK = 0,
       
    54         kUnSupportedMethod,
       
    55         kDataError,
       
    56         kCRCError
       
    57       };
       
    58     }
       
    59   }
       
    60   namespace NUpdate
       
    61   {
       
    62     namespace NOperationResult
       
    63     {
       
    64       enum 
       
    65       {
       
    66         kOK = 0,
       
    67         kError
       
    68       };
       
    69     }
       
    70   }
       
    71 }
       
    72 
       
    73 ARCHIVE_INTERFACE(IArchiveOpenCallback, 0x10)
       
    74 {
       
    75   STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) PURE;
       
    76   STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) PURE;
       
    77 };
       
    78 
       
    79 
       
    80 ARCHIVE_INTERFACE_SUB(IArchiveExtractCallback, IProgress, 0x20)
       
    81 {
       
    82   STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, 
       
    83       Int32 askExtractMode) PURE;
       
    84   // GetStream OUT: S_OK - OK, S_FALSE - skeep this file
       
    85   STDMETHOD(PrepareOperation)(Int32 askExtractMode) PURE;
       
    86   STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) PURE;
       
    87 };
       
    88 
       
    89 
       
    90 ARCHIVE_INTERFACE(IArchiveOpenVolumeCallback, 0x30)
       
    91 {
       
    92   STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) PURE;
       
    93   STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) PURE;
       
    94 };
       
    95 
       
    96 
       
    97 ARCHIVE_INTERFACE(IInArchiveGetStream, 0x40)
       
    98 {
       
    99   STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream) PURE;  
       
   100 };
       
   101 
       
   102 
       
   103 ARCHIVE_INTERFACE(IArchiveOpenSetSubArchiveName, 0x50)
       
   104 {
       
   105   STDMETHOD(SetSubArchiveName)(const wchar_t *name) PURE;
       
   106 };
       
   107 
       
   108 
       
   109 /*
       
   110 IInArchive::Extract:
       
   111   indices must be sorted 
       
   112   numItems = 0xFFFFFFFF means "all files"
       
   113   testMode != 0 means "test files without writing to outStream"
       
   114 */
       
   115 
       
   116 #define INTERFACE_IInArchive(x) \
       
   117   STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback) x; \
       
   118   STDMETHOD(Close)() x; \
       
   119   STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
       
   120   STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
       
   121   STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) x; \
       
   122   STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) x; \
       
   123   STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
       
   124   STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
       
   125   STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties) x; \
       
   126   STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x;
       
   127 
       
   128 ARCHIVE_INTERFACE(IInArchive, 0x60)
       
   129 {
       
   130   INTERFACE_IInArchive(PURE)
       
   131 };
       
   132 
       
   133 
       
   134 ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback, IProgress, 0x80)
       
   135 {
       
   136   STDMETHOD(GetUpdateItemInfo)(UInt32 index, 
       
   137       Int32 *newData, // 1 - new data, 0 - old data
       
   138       Int32 *newProperties, // 1 - new properties, 0 - old properties
       
   139       UInt32 *indexInArchive // -1 if there is no in archive, or if doesn't matter
       
   140       ) PURE;
       
   141   STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE;
       
   142   STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream) PURE;
       
   143   STDMETHOD(SetOperationResult)(Int32 operationResult) PURE;
       
   144 };
       
   145 
       
   146 
       
   147 ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback2, IArchiveUpdateCallback, 0x82)
       
   148 {
       
   149   STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size) PURE;
       
   150   STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream) PURE;
       
   151 };
       
   152 
       
   153 
       
   154 #define INTERFACE_IOutArchive(x) \
       
   155   STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems, IArchiveUpdateCallback *updateCallback) x; \
       
   156   STDMETHOD(GetFileTimeType)(UInt32 *type) x;
       
   157 
       
   158 ARCHIVE_INTERFACE(IOutArchive, 0xA0)
       
   159 {
       
   160   INTERFACE_IOutArchive(PURE)
       
   161 };
       
   162 
       
   163 
       
   164 ARCHIVE_INTERFACE(ISetProperties, 0x03)
       
   165 {
       
   166   STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties) PURE;
       
   167 };
       
   168 
       
   169 
       
   170 #define IMP_IInArchive_GetProp(k) \
       
   171   (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
       
   172     { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
       
   173     const STATPROPSTG &srcItem = k[index]; \
       
   174     *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \
       
   175 
       
   176 #define IMP_IInArchive_GetProp_WITH_NAME(k) \
       
   177   (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
       
   178     { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
       
   179     const STATPROPSTG &srcItem = k[index]; \
       
   180     *propID = srcItem.propid; *varType = srcItem.vt; \
       
   181     if (srcItem.lpwstrName == 0) *name = 0; else *name = ::SysAllocString(srcItem.lpwstrName); return S_OK; } \
       
   182 
       
   183 #define IMP_IInArchive_Props \
       
   184   STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) \
       
   185     { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
       
   186   STDMETHODIMP CHandler::GetPropertyInfo IMP_IInArchive_GetProp(kProps)
       
   187 
       
   188 #define IMP_IInArchive_Props_WITH_NAME \
       
   189   STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) \
       
   190     { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
       
   191   STDMETHODIMP CHandler::GetPropertyInfo IMP_IInArchive_GetProp_WITH_NAME(kProps)
       
   192 
       
   193 
       
   194 #define IMP_IInArchive_ArcProps \
       
   195   STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
       
   196     { *numProperties = sizeof(kArcProps) / sizeof(kArcProps[0]); return S_OK; } \
       
   197   STDMETHODIMP CHandler::GetArchivePropertyInfo IMP_IInArchive_GetProp(kArcProps)
       
   198 
       
   199 #define IMP_IInArchive_ArcProps_NO \
       
   200   STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
       
   201     { *numProperties = 0; return S_OK; } \
       
   202   STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32, BSTR *, PROPID *, VARTYPE *) \
       
   203     { return E_NOTIMPL; } \
       
   204   STDMETHODIMP CHandler::GetArchiveProperty(PROPID, PROPVARIANT *value) \
       
   205     { value->vt = VT_EMPTY; return S_OK; } 
       
   206 
       
   207 #endif