1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// 7zProperties.cpp 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "StdAfx.h" 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "7zProperties.h" 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "7zHeader.h" 7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync#include "7zHandler.h" 8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// #define _MULTI_PACK 10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 11baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace NArchive { 12baa3858d3f5d128a5c8466b700098109edcad5f2repo syncnamespace N7z { 13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 14baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstruct CPropMap 15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync UInt64 FilePropID; 17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync STATPROPSTG StatPROPSTG; 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 20cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbeckystatic const CPropMap kPropMap[] = 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kName, { NULL, kpidPath, VT_BSTR } }, 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kSize, { NULL, kpidSize, VT_UI8 } }, 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kPackInfo, { NULL, kpidPackSize, VT_UI8 } }, 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifdef _MULTI_PACK 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 100, { L"Pack0", kpidPackedSize0, VT_UI8 } }, 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 101, { L"Pack1", kpidPackedSize1, VT_UI8 } }, 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 102, { L"Pack2", kpidPackedSize2, VT_UI8 } }, 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 103, { L"Pack3", kpidPackedSize3, VT_UI8 } }, 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 104, { L"Pack4", kpidPackedSize4, VT_UI8 } }, 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kCTime, { NULL, kpidCTime, VT_FILETIME } }, 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kMTime, { NULL, kpidMTime, VT_FILETIME } }, 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kATime, { NULL, kpidATime, VT_FILETIME } }, 37cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky { NID::kWinAttrib, { NULL, kpidAttrib, VT_UI4 } }, 38baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kStartPos, { NULL, kpidPosition, VT_UI4 } }, 39baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 40baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kCRC, { NULL, kpidCRC, VT_UI4 } }, 41baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 42cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky// { NID::kIsAux, { NULL, kpidIsAux, VT_BOOL } }, 43baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { NID::kAnti, { NULL, kpidIsAnti, VT_BOOL } } 44baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 45baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef _SFX 46baa3858d3f5d128a5c8466b700098109edcad5f2repo sync , 47baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 97, { NULL,kpidEncrypted, VT_BOOL } }, 48baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 98, { NULL,kpidMethod, VT_BSTR } }, 49baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 99, { NULL,kpidBlock, VT_UI4 } } 50baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 51baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}; 52baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 53baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstatic int FindPropInMap(UInt64 filePropID) 54baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 55cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky for (int i = 0; i < ARRAY_SIZE(kPropMap); i++) 56baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (kPropMap[i].FilePropID == filePropID) 57baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return i; 58baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return -1; 59baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 60baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 61baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstatic void CopyOneItem(CRecordVector<UInt64> &src, 62baa3858d3f5d128a5c8466b700098109edcad5f2repo sync CRecordVector<UInt64> &dest, UInt32 item) 63baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 64cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky FOR_VECTOR (i, src) 65baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (src[i] == item) 66baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 67baa3858d3f5d128a5c8466b700098109edcad5f2repo sync dest.Add(item); 68baa3858d3f5d128a5c8466b700098109edcad5f2repo sync src.Delete(i); 69baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return; 70baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 71baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 72baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 73baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstatic void RemoveOneItem(CRecordVector<UInt64> &src, UInt32 item) 74baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 75cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky FOR_VECTOR (i, src) 76baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (src[i] == item) 77baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 78baa3858d3f5d128a5c8466b700098109edcad5f2repo sync src.Delete(i); 79baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return; 80baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 81baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 82baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 83baa3858d3f5d128a5c8466b700098109edcad5f2repo syncstatic void InsertToHead(CRecordVector<UInt64> &dest, UInt32 item) 84baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 85cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky FOR_VECTOR (i, dest) 86baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (dest[i] == item) 87baa3858d3f5d128a5c8466b700098109edcad5f2repo sync { 88baa3858d3f5d128a5c8466b700098109edcad5f2repo sync dest.Delete(i); 89baa3858d3f5d128a5c8466b700098109edcad5f2repo sync break; 90baa3858d3f5d128a5c8466b700098109edcad5f2repo sync } 91baa3858d3f5d128a5c8466b700098109edcad5f2repo sync dest.Insert(0, item); 92baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 93baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 94cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky#define COPY_ONE_ITEM(id) CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::id); 95cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky 96baa3858d3f5d128a5c8466b700098109edcad5f2repo syncvoid CHandler::FillPopIDs() 97baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 98baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Clear(); 99baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 100baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifdef _7Z_VOL 101baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if(_volumes.Size() < 1) 102baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return; 103baa3858d3f5d128a5c8466b700098109edcad5f2repo sync const CVolume &volume = _volumes.Front(); 104baa3858d3f5d128a5c8466b700098109edcad5f2repo sync const CArchiveDatabaseEx &_db = volume.Database; 105baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 106baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 107cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky CRecordVector<UInt64> fileInfoPopIDs = _db.ArcInfo.FileInfoPopIDs; 108baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 109baa3858d3f5d128a5c8466b700098109edcad5f2repo sync RemoveOneItem(fileInfoPopIDs, NID::kEmptyStream); 110baa3858d3f5d128a5c8466b700098109edcad5f2repo sync RemoveOneItem(fileInfoPopIDs, NID::kEmptyFile); 111cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky /* 112cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky RemoveOneItem(fileInfoPopIDs, NID::kParent); 113cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky RemoveOneItem(fileInfoPopIDs, NID::kNtSecure); 114cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky */ 115cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky 116cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kName); 117cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kAnti); 118cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kSize); 119cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kPackInfo); 120cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kCTime); 121cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kMTime); 122cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kATime); 123cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kWinAttrib); 124cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kCRC); 125cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky COPY_ONE_ITEM(kComment); 126baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 127baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs += fileInfoPopIDs; 128baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 129baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef _SFX 130baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(97); 131baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(98); 132baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(99); 133baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 134baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifdef _MULTI_PACK 135baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(100); 136baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(101); 137baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(102); 138baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(103); 139baa3858d3f5d128a5c8466b700098109edcad5f2repo sync _fileInfoPopIDs.Add(104); 140baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 141baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 142baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #ifndef _SFX 143baa3858d3f5d128a5c8466b700098109edcad5f2repo sync InsertToHead(_fileInfoPopIDs, NID::kMTime); 144baa3858d3f5d128a5c8466b700098109edcad5f2repo sync InsertToHead(_fileInfoPopIDs, NID::kPackInfo); 145baa3858d3f5d128a5c8466b700098109edcad5f2repo sync InsertToHead(_fileInfoPopIDs, NID::kSize); 146baa3858d3f5d128a5c8466b700098109edcad5f2repo sync InsertToHead(_fileInfoPopIDs, NID::kName); 147baa3858d3f5d128a5c8466b700098109edcad5f2repo sync #endif 148baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 149baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 150cd66d540cead3f8200b0c73bad9c276d67896c3dDavid SrbeckySTDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProps) 151baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 152cd66d540cead3f8200b0c73bad9c276d67896c3dDavid Srbecky *numProps = _fileInfoPopIDs.Size(); 153baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return S_OK; 154baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 155baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 156baa3858d3f5d128a5c8466b700098109edcad5f2repo syncSTDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) 157baa3858d3f5d128a5c8466b700098109edcad5f2repo sync{ 158baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if ((int)index >= _fileInfoPopIDs.Size()) 159baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return E_INVALIDARG; 160baa3858d3f5d128a5c8466b700098109edcad5f2repo sync int indexInMap = FindPropInMap(_fileInfoPopIDs[index]); 161baa3858d3f5d128a5c8466b700098109edcad5f2repo sync if (indexInMap == -1) 162baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return E_INVALIDARG; 163baa3858d3f5d128a5c8466b700098109edcad5f2repo sync const STATPROPSTG &srcItem = kPropMap[indexInMap].StatPROPSTG; 164baa3858d3f5d128a5c8466b700098109edcad5f2repo sync *propID = srcItem.propid; 165baa3858d3f5d128a5c8466b700098109edcad5f2repo sync *varType = srcItem.vt; 166baa3858d3f5d128a5c8466b700098109edcad5f2repo sync *name = 0; 167baa3858d3f5d128a5c8466b700098109edcad5f2repo sync return S_OK; 168baa3858d3f5d128a5c8466b700098109edcad5f2repo sync} 169baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 170baa3858d3f5d128a5c8466b700098109edcad5f2repo sync}} 171