diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2008-08-13 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:56 +0300 |
commit | 173c07e166fdf6fcd20f18ea73008f1b628945df (patch) | |
tree | 13ebea85cdc4c16ae93714ff0627ee9f91ad7e08 /CPP/7zip/UI/Agent | |
parent | 3901bf0ab88106a5b031cba7bc18d60cdebf7eef (diff) |
4.59 beta
Diffstat (limited to 'CPP/7zip/UI/Agent')
-rwxr-xr-x | CPP/7zip/UI/Agent/Agent.cpp | 103 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/Agent.h | 36 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/AgentOut.cpp | 232 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/AgentProxy.cpp | 16 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/AgentProxy.h | 2 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/ArchiveFolder.cpp | 20 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp | 4 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/ArchiveFolderOut.cpp | 25 | ||||
-rwxr-xr-x | CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp | 6 |
9 files changed, 220 insertions, 224 deletions
diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp index 82ae33bc..b0cb559f 100755 --- a/CPP/7zip/UI/Agent/Agent.cpp +++ b/CPP/7zip/UI/Agent/Agent.cpp @@ -22,9 +22,9 @@ extern "C" using namespace NWindows; STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder) -{ - *agentFolder = this; - return S_OK; +{ + *agentFolder = this; + return S_OK; } void CAgentFolder::LoadFolder(CProxyFolder *folder) @@ -137,13 +137,13 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI const CProxyFolder &item = folder->Folders[realIndex]; if (!_flatMode && propID == kpidSize) prop = item.Size; - else if (!_flatMode && propID == kpidPackedSize) + else if (!_flatMode && propID == kpidPackSize) prop = item.PackSize; else switch(propID) { - case kpidIsFolder: prop = true; break; - case kpidNumSubFolders: prop = item.NumSubFolders; break; + case kpidIsDir: prop = true; break; + case kpidNumSubDirs: prop = item.NumSubFolders; break; case kpidNumSubFiles: prop = item.NumSubFiles; break; case kpidName: prop = item.Name; break; case kpidCRC: @@ -153,7 +153,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI RINOK(_agentSpec->GetArchive()->GetProperty(item.Index, propID, value)); } if (item.CrcIsDefined && value->vt == VT_EMPTY) - prop = item.Crc; + prop = item.Crc; break; } case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break; @@ -169,10 +169,10 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI const CProxyFile &item = folder->Files[realIndex]; switch(propID) { - case kpidIsFolder: prop = false; break; + case kpidIsDir: prop = false; break; case kpidName: prop = item.Name; break; case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break; - default: + default: return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value); } } @@ -238,9 +238,9 @@ STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder) COM_TRY_END } -STATPROPSTG kProperties[] = +STATPROPSTG kProperties[] = { - { NULL, kpidNumSubFolders, VT_UI4}, + { NULL, kpidNumSubDirs, VT_UI4}, { NULL, kpidNumSubFiles, VT_UI4}, { NULL, kpidPrefix, VT_BSTR} }; @@ -287,11 +287,11 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro COM_TRY_END } -STATPROPSTG kFolderProps[] = +STATPROPSTG kFolderProps[] = { { NULL, kpidSize, VT_UI8}, - { NULL, kpidPackedSize, VT_UI8}, - { NULL, kpidNumSubFolders, VT_UI4}, + { NULL, kpidPackSize, VT_UI8}, + { NULL, kpidNumSubDirs, VT_UI4}, { NULL, kpidNumSubFiles, VT_UI4}, { NULL, kpidCRC, VT_UI4} }; @@ -304,12 +304,12 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) NWindows::NCOM::CPropVariant prop; switch(propID) { - case kpidSize: prop = _proxyFolderItem->Size; break; - case kpidPackedSize: prop = _proxyFolderItem->PackSize; break; - case kpidNumSubFolders: prop = _proxyFolderItem->NumSubFolders; break; - case kpidNumSubFiles: prop = _proxyFolderItem->NumSubFiles; break; - case kpidName: prop = _proxyFolderItem->Name; break; - case kpidPath: prop = _proxyFolderItem->GetFullPathPrefix(); break; + case kpidSize: prop = _proxyFolderItem->Size; break; + case kpidPackSize: prop = _proxyFolderItem->PackSize; break; + case kpidNumSubDirs: prop = _proxyFolderItem->NumSubFolders; break; + case kpidNumSubFiles: prop = _proxyFolderItem->NumSubFiles; break; + case kpidName: prop = _proxyFolderItem->Name; break; + case kpidPath: prop = _proxyFolderItem->GetFullPathPrefix(); break; case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break; case kpidCRC: if (_proxyFolderItem->CrcIsDefined) prop = _proxyFolderItem->Crc; break; } @@ -373,10 +373,10 @@ void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntV HeapSort(&realIndices.Front(), realIndices.Size()); } -STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices, - UInt32 numItems, - NExtract::NPathMode::EEnum pathMode, - NExtract::NOverwriteMode::EEnum overwriteMode, +STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices, + UInt32 numItems, + NExtract::NPathMode::EEnum pathMode, + NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, INT32 testMode, IFolderArchiveExtractCallback *extractCallback2) @@ -399,20 +399,20 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices, extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode); - extractCallbackSpec->Init(_agentSpec->GetArchive(), - extractCallback2, + extractCallbackSpec->Init(_agentSpec->GetArchive(), + extractCallback2, false, (path ? path : L""), - pathParts, + pathParts, _agentSpec->DefaultName, - _agentSpec->DefaultTime, - _agentSpec->DefaultAttributes, + _agentSpec->DefaultTime, + _agentSpec->DefaultAttrib, (UInt64)(Int64)-1 // ,_agentSpec->_srcDirectoryPrefix ); CUIntVector realIndices; GetRealIndices(indices, numItems, realIndices); - return _agentSpec->GetArchive()->Extract(&realIndices.Front(), + return _agentSpec->GetArchive()->Extract(&realIndices.Front(), realIndices.Size(), testMode, extractCallback); COM_TRY_END } @@ -433,7 +433,7 @@ CAgent::~CAgent() } STDMETHODIMP CAgent::Open( - const wchar_t *filePath, + const wchar_t *filePath, BSTR *archiveType, // CLSID *clsIDResult, IArchiveOpenCallback *openArchiveCallback) @@ -443,7 +443,7 @@ STDMETHODIMP CAgent::Open( NFile::NFind::CFileInfoW fileInfo; if (!NFile::NFind::FindFile(_archiveFilePath, fileInfo)) return ::GetLastError(); - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) return E_FAIL; CArcInfoEx archiverInfo0, archiverInfo1; @@ -452,14 +452,13 @@ STDMETHODIMP CAgent::Open( _compressCodecsInfo = _codecs; RINOK(_codecs->Load()); - HRESULT res = OpenArchive(_codecs, _archiveFilePath, _archiveLink, openArchiveCallback); + RINOK(OpenArchive(_codecs, CIntVector(), _archiveFilePath, _archiveLink, openArchiveCallback)); // _archive = _archiveLink.GetArchive(); DefaultName = _archiveLink.GetDefaultItemName(); const CArcInfoEx &ai = _codecs->Formats[_archiveLink.GetArchiverIndex()]; - RINOK(res); - DefaultTime = fileInfo.LastWriteTime; - DefaultAttributes = fileInfo.Attributes; + DefaultTime = fileInfo.MTime; + DefaultAttrib = fileInfo.Attrib; ArchiveType = ai.Name; if (archiveType != 0) { @@ -470,7 +469,7 @@ STDMETHODIMP CAgent::Open( COM_TRY_END } -STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback * /* openArchiveCallback */) +STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback) { COM_TRY_BEGIN if (_proxyArchive != NULL) @@ -478,7 +477,7 @@ STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback * /* openArchiveCallback */) delete _proxyArchive; _proxyArchive = NULL; } - RINOK(ReOpenArchive(_codecs, _archiveLink, _archiveFilePath)); + RINOK(ReOpenArchive(_codecs, _archiveLink, _archiveFilePath, openArchiveCallback)); return ReadItems(); COM_TRY_END } @@ -508,10 +507,10 @@ HRESULT CAgent::ReadItems() if (_proxyArchive != NULL) return S_OK; _proxyArchive = new CProxyArchive(); - return _proxyArchive->Load(GetArchive(), - DefaultName, - // _defaultTime, - // _defaultAttributes, + return _proxyArchive->Load(GetArchive(), + DefaultName, + // _defaultTime, + // _defaultAttrib, NULL); } @@ -529,8 +528,8 @@ STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder) STDMETHODIMP CAgent::Extract( - NExtract::NPathMode::EEnum pathMode, - NExtract::NOverwriteMode::EEnum overwriteMode, + NExtract::NPathMode::EEnum pathMode, + NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, INT32 testMode, IFolderArchiveExtractCallback *extractCallback2) @@ -539,14 +538,14 @@ STDMETHODIMP CAgent::Extract( CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback; CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec; extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode); - extractCallbackSpec->Init(GetArchive(), - extractCallback2, + extractCallbackSpec->Init(GetArchive(), + extractCallback2, false, path, - UStringVector(), + UStringVector(), DefaultName, - DefaultTime, - DefaultAttributes, + DefaultTime, + DefaultAttrib, (UInt64)(Int64)-1 // ,_srcDirectoryPrefix ); @@ -561,7 +560,7 @@ STDMETHODIMP CAgent::GetNumberOfProperties(UInt32 *numProperties) COM_TRY_END } -STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index, +STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { COM_TRY_BEGIN @@ -586,11 +585,11 @@ STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UInt32 *numProperties) COM_TRY_END } -STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index, +STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) { COM_TRY_BEGIN - return GetArchive()->GetArchivePropertyInfo(index, + return GetArchive()->GetArchivePropertyInfo(index, name, propID, varType); COM_TRY_END } diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h index 0f2d7573..64fb31f6 100755 --- a/CPP/7zip/UI/Agent/Agent.h +++ b/CPP/7zip/UI/Agent/Agent.h @@ -21,7 +21,7 @@ class CAgentFolder; DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC) { - STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder) PURE; + STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder) PURE; }; struct CProxyItem @@ -32,7 +32,7 @@ struct CProxyItem class CAgent; -class CAgentFolder: +class CAgentFolder: public IFolderFolder, public IFolderProperties, public IGetFolderArchiveProperties, @@ -46,7 +46,7 @@ class CAgentFolder: { public: - MY_QUERYINTERFACE_BEGIN + MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_ENTRY(IFolderFolder) MY_QUERYINTERFACE_ENTRY(IFolderProperties) MY_QUERYINTERFACE_ENTRY(IGetFolderArchiveProperties) @@ -69,9 +69,9 @@ public: STDMETHOD(GetFolderArchiveProperties)(IFolderArchiveProperties **object); // IArchiveFolder - STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems, - NExtract::NPathMode::EEnum pathMode, - NExtract::NOverwriteMode::EEnum overwriteMode, + STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems, + NExtract::NPathMode::EEnum pathMode, + NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, INT32 testMode, IFolderArchiveExtractCallback *extractCallback); @@ -103,7 +103,7 @@ public: bool deleteOperation, bool createFolderOperation, bool renameOperation, - const wchar_t *newItemName, + const wchar_t *newItemName, const NUpdateArchive::CActionSet *actionSet, const UINT32 *indices, UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback100); @@ -126,7 +126,7 @@ public: private: }; -class CAgent: +class CAgent: public IInFolderArchive, public IFolderArchiveProperties, #ifndef EXTRACT_ONLY @@ -137,7 +137,7 @@ class CAgent: { public: - MY_QUERYINTERFACE_BEGIN + MY_QUERYINTERFACE_BEGIN MY_QUERYINTERFACE_ENTRY(IInFolderArchive) MY_QUERYINTERFACE_ENTRY(IFolderArchiveProperties) #ifndef EXTRACT_ONLY @@ -154,19 +154,19 @@ public: INTERFACE_IOutFolderArchive(;) HRESULT CommonUpdate( - const wchar_t *newArchiveName, + const wchar_t *newArchiveName, int numUpdateItems, IArchiveUpdateCallback *updateCallback); HRESULT CreateFolder( - const wchar_t *newArchiveName, - const wchar_t *folderName, + const wchar_t *newArchiveName, + const wchar_t *folderName, IFolderArchiveUpdateCallback *updateCallback100); HRESULT RenameItem( - const wchar_t *newArchiveName, - const UINT32 *indices, UINT32 numItems, - const wchar_t *newItemName, + const wchar_t *newArchiveName, + const UINT32 *indices, UINT32 numItems, + const wchar_t *newItemName, IFolderArchiveUpdateCallback *updateCallback100); // ISetProperties @@ -189,7 +189,7 @@ public: UString DefaultName; FILETIME DefaultTime; - UINT32 DefaultAttributes; + DWORD DefaultAttrib; UString ArchiveType; @@ -211,7 +211,7 @@ public: }; #ifdef NEW_FOLDER_INTERFACE -class CArchiveFolderManager: +class CArchiveFolderManager: public IFolderManager, public CMyUnknownImp { @@ -223,7 +223,7 @@ public: CArchiveFolderManager(): _codecs(0) {} private: void LoadFormats(); - int FindFormat(const UString &type); + int FindFormat(const UString &type); CCodecs *_codecs; CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo; }; diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp index 7976e1a2..2e953aed 100755 --- a/CPP/7zip/UI/Agent/AgentOut.cpp +++ b/CPP/7zip/UI/Agent/AgentOut.cpp @@ -2,13 +2,14 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" #include "Common/IntToString.h" +#include "Common/StringConvert.h" #include "Windows/Defs.h" +#include "Windows/FileDir.h" #include "Windows/PropVariant.h" #include "Windows/PropVariantConversions.h" -#include "Windows/FileDir.h" +#include "Windows/Time.h" #include "../../Compress/Copy/CopyCoder.h" #include "../../Common/FileStreams.h" @@ -54,7 +55,7 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder) for (;;) { CMyComPtr<IFolderFolder> newFolder; - folderItem->BindToParentFolder(&newFolder); + folderItem->BindToParentFolder(&newFolder); if (newFolder == NULL) break; @@ -73,22 +74,22 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder) return S_OK; } -STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix, - const wchar_t **names, UINT32 numNames) +STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix, + const wchar_t **names, UInt32 numNames) { _folderPrefix = folderPrefix; _names.Clear(); _names.Reserve(numNames); - for (UINT32 i = 0; i < numNames; i++) + for (UInt32 i = 0; i < numNames; i++) _names.Add(names[i]); return S_OK; } -static HRESULT GetFileTime(CAgent *agent, UINT32 itemIndex, FILETIME &fileTime) +static HRESULT GetFileTime(CAgent *agent, UInt32 itemIndex, FILETIME &fileTime) { CPropVariant property; - RINOK(agent->GetArchive()->GetProperty(itemIndex, kpidLastWriteTime, &property)); + RINOK(agent->GetArchive()->GetProperty(itemIndex, kpidMTime, &property)); if (property.vt == VT_FILETIME) fileTime = property.filetime; else if (property.vt == VT_EMPTY) @@ -99,54 +100,54 @@ static HRESULT GetFileTime(CAgent *agent, UINT32 itemIndex, FILETIME &fileTime) } static HRESULT EnumerateArchiveItems(CAgent *agent, - const CProxyFolder &item, + const CProxyFolder &item, const UString &prefix, - CObjectVector<CArchiveItem> &archiveItems) + CObjectVector<CArcItem> &arcItems) { int i; - for(i = 0; i < item.Files.Size(); i++) + for (i = 0; i < item.Files.Size(); i++) { const CProxyFile &fileItem = item.Files[i]; - CArchiveItem archiveItem; + CArcItem ai; - RINOK(::GetFileTime(agent, fileItem.Index, archiveItem.LastWriteTime)); + RINOK(::GetFileTime(agent, fileItem.Index, ai.MTime)); CPropVariant property; agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property); - archiveItem.SizeIsDefined = (property.vt != VT_EMPTY); - if (archiveItem.SizeIsDefined) - archiveItem.Size = ConvertPropVariantToUInt64(property); - archiveItem.IsDirectory = false; - archiveItem.Name = prefix + fileItem.Name; - archiveItem.Censored = true; // test it - archiveItem.IndexInServer = fileItem.Index; - archiveItems.Add(archiveItem); + ai.SizeDefined = (property.vt != VT_EMPTY); + if (ai.SizeDefined) + ai.Size = ConvertPropVariantToUInt64(property); + ai.IsDir = false; + ai.Name = prefix + fileItem.Name; + ai.Censored = true; // test it + ai.IndexInServer = fileItem.Index; + arcItems.Add(ai); } - for(i = 0; i < item.Folders.Size(); i++) + for (i = 0; i < item.Folders.Size(); i++) { const CProxyFolder &dirItem = item.Folders[i]; UString fullName = prefix + dirItem.Name; if(dirItem.IsLeaf) { - CArchiveItem archiveItem; - RINOK(::GetFileTime(agent, dirItem.Index, archiveItem.LastWriteTime)); - archiveItem.IsDirectory = true; - archiveItem.SizeIsDefined = false; - archiveItem.Name = fullName; - archiveItem.Censored = true; // test it - archiveItem.IndexInServer = dirItem.Index; - archiveItems.Add(archiveItem); + CArcItem ai; + RINOK(::GetFileTime(agent, dirItem.Index, ai.MTime)); + ai.IsDir = true; + ai.SizeDefined = false; + ai.Name = fullName; + ai.Censored = true; // test it + ai.IndexInServer = dirItem.Index; + arcItems.Add(ai); } - RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(L'\\'), archiveItems)); + RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(L'\\'), arcItems)); } return S_OK; } STDMETHODIMP CAgent::DoOperation( - CCodecs *codecs, + CCodecs *codecs, int formatIndex, - const wchar_t *newArchiveName, - const Byte *stateActions, + const wchar_t *newArchiveName, + const Byte *stateActions, const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback100) { @@ -157,16 +158,16 @@ STDMETHODIMP CAgent::DoOperation( for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++) actionSet.StateActions[i] = (NUpdateArchive::NPairAction::EEnum)stateActions[i]; - CObjectVector<CDirItem> dirItems; + CDirItems dirItems; - UString folderPrefix = _folderPrefix; - NFile::NName::NormalizeDirPathPrefix(folderPrefix); - UStringVector errorPaths; - CRecordVector<DWORD> errorCodes; - ::EnumerateDirItems(folderPrefix, _names, _archiveNamePrefix, dirItems, errorPaths, errorCodes); - if (errorCodes.Size() > 0) { - return errorCodes.Front(); + UString folderPrefix = _folderPrefix; + NFile::NName::NormalizeDirPathPrefix(folderPrefix); + UStringVector errorPaths; + CRecordVector<DWORD> errorCodes; + dirItems.EnumerateDirItems2(folderPrefix, _archiveNamePrefix, _names, errorPaths, errorCodes); + if (errorCodes.Size() > 0) + return errorCodes.Front(); } CMyComPtr<IOutArchive> outArchive; @@ -193,7 +194,7 @@ STDMETHODIMP CAgent::DoOperation( } NFileTimeType::EEnum fileTimeType; - UINT32 value; + UInt32 value; RINOK(outArchive->GetFileTimeType(&value)); switch(value) @@ -207,19 +208,21 @@ STDMETHODIMP CAgent::DoOperation( return E_FAIL; } - CObjectVector<CUpdatePair> updatePairs; - CObjectVector<CArchiveItem> archiveItems; + CObjectVector<CArcItem> arcItems; if (GetArchive()) { RINOK(ReadItems()); - EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", archiveItems); + EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems); } - GetUpdatePairInfoList(dirItems, archiveItems, fileTimeType, updatePairs); - - CObjectVector<CUpdatePair2> updatePairs2; - UpdateProduce(updatePairs, actionSet, updatePairs2); + CRecordVector<CUpdatePair2> updatePairs2; + + { + CRecordVector<CUpdatePair> updatePairs; + GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs); + UpdateProduce(updatePairs, actionSet, updatePairs2); + } UInt32 numFiles = 0; for (i = 0; i < updatePairs2.Size(); i++) @@ -236,9 +239,8 @@ STDMETHODIMP CAgent::DoOperation( CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback; CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec ); - updateCallbackSpec->DirPrefix = folderPrefix; updateCallbackSpec->DirItems = &dirItems; - updateCallbackSpec->ArchiveItems = &archiveItems; + updateCallbackSpec->ArcItems = &arcItems; updateCallbackSpec->UpdatePairs = &updatePairs2; updateCallbackSpec->Archive = GetArchive(); updateCallbackSpec->Callback = &updateCallbackAgent; @@ -305,12 +307,12 @@ STDMETHODIMP CAgent::DoOperation( } STDMETHODIMP CAgent::DoOperation2( - const wchar_t *newArchiveName, - const Byte *stateActions, + const wchar_t *newArchiveName, + const Byte *stateActions, const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback100) { - return DoOperation(_codecs, -1, newArchiveName, + return DoOperation(_codecs, -1, newArchiveName, stateActions, sfxModule, updateCallback100); } @@ -370,8 +372,8 @@ HRESULT CAgent::CommonUpdate( STDMETHODIMP CAgent::DeleteItems( - const wchar_t *newArchiveName, - const UINT32 *indices, UINT32 numItems, + const wchar_t *newArchiveName, + const UInt32 *indices, UInt32 numItems, IFolderArchiveUpdateCallback *updateCallback100) { if (!CanUpdate()) @@ -383,7 +385,7 @@ STDMETHODIMP CAgent::DeleteItems( CUIntVector realIndices; _agentFolder->GetRealIndices(indices, numItems, realIndices); - CObjectVector<CUpdatePair2> updatePairs; + CRecordVector<CUpdatePair2> updatePairs; int curIndex = 0; UInt32 numItemsInArchive; RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive)); @@ -395,13 +397,11 @@ STDMETHODIMP CAgent::DeleteItems( curIndex++; continue; } - CUpdatePair2 updatePair; - updatePair.NewData = updatePair.NewProperties = false; - updatePair.ExistInArchive = true; - updatePair.ExistOnDisk = false; - updatePair.IsAnti = false; // check it. Maybe it can be undefined - updatePair.ArchiveItemIndex = i; - updatePairs.Add(updatePair); + CUpdatePair2 up2; + up2.NewData = up2.NewProps = false; + up2.IsAnti = false; // check it. Maybe it can be undefined + up2.ArcIndex = i; + updatePairs.Add(up2); } updateCallbackSpec->UpdatePairs = &updatePairs; updateCallbackSpec->Archive = GetArchive(); @@ -410,8 +410,8 @@ STDMETHODIMP CAgent::DeleteItems( } HRESULT CAgent::CreateFolder( - const wchar_t *newArchiveName, - const wchar_t *folderName, + const wchar_t *newArchiveName, + const wchar_t *folderName, IFolderArchiveUpdateCallback *updateCallback100) { if (!CanUpdate()) @@ -421,44 +421,38 @@ HRESULT CAgent::CreateFolder( CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback; CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec); - CObjectVector<CUpdatePair2> updatePairs; - UINT32 numItemsInArchive; + CRecordVector<CUpdatePair2> updatePairs; + UInt32 numItemsInArchive; RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive)); for (UInt32 i = 0; i < numItemsInArchive; i++) { - CUpdatePair2 updatePair; - updatePair.NewData = updatePair.NewProperties = false; - updatePair.ExistInArchive = true; - updatePair.ExistOnDisk = false; - updatePair.IsAnti = false; // check it. - updatePair.ArchiveItemIndex = i; - updatePairs.Add(updatePair); + CUpdatePair2 up2; + up2.NewData = up2.NewProps = false; + up2.IsAnti = false; // check it. + up2.ArcIndex = i; + updatePairs.Add(up2); } - CUpdatePair2 updatePair; - updatePair.NewData = updatePair.NewProperties = true; - updatePair.ExistInArchive = false; - updatePair.ExistOnDisk = true; - updatePair.IsAnti = false; - updatePair.ArchiveItemIndex = -1; - updatePair.DirItemIndex = 0; + CUpdatePair2 up2; + up2.NewData = up2.NewProps = true; + up2.IsAnti = false; + up2.DirIndex = 0; + + updatePairs.Add(up2); - updatePairs.Add(updatePair); + updatePairs.ReserveDown(); - CObjectVector<CDirItem> dirItems; - CDirItem dirItem; + CDirItems dirItems; + CDirItem di; - dirItem.Attributes = FILE_ATTRIBUTE_DIRECTORY; - dirItem.Size = 0; - dirItem.Name = _agentFolder->_proxyFolderItem->GetFullPathPrefix() + folderName; + di.Attrib = FILE_ATTRIBUTE_DIRECTORY; + di.Size = 0; + di.Name = _agentFolder->_proxyFolderItem->GetFullPathPrefix() + folderName; - SYSTEMTIME systemTime; - FILETIME fileTime; - ::GetSystemTime(&systemTime); - ::SystemTimeToFileTime(&systemTime, &fileTime); - dirItem.LastAccessTime = dirItem.LastWriteTime = - dirItem.CreationTime = fileTime; + FILETIME ft; + NTime::GetCurUtcFileTime(ft); + di.CTime = di.ATime = di.MTime = ft; - dirItems.Add(dirItem); + dirItems.Items.Add(di); updateCallbackSpec->Callback = &updateCallbackAgent; updateCallbackSpec->DirItems = &dirItems; @@ -469,9 +463,9 @@ HRESULT CAgent::CreateFolder( HRESULT CAgent::RenameItem( - const wchar_t *newArchiveName, - const UINT32 *indices, UINT32 numItems, - const wchar_t *newItemName, + const wchar_t *newArchiveName, + const UInt32 *indices, UInt32 numItems, + const wchar_t *newItemName, IFolderArchiveUpdateCallback *updateCallback100) { if (!CanUpdate()) @@ -490,25 +484,22 @@ HRESULT CAgent::RenameItem( UString oldItemPath = fullPrefix + _agentFolder->GetName(indices[0]); UString newItemPath = fullPrefix + newItemName; - CObjectVector<CUpdatePair2> updatePairs; + CRecordVector<CUpdatePair2> updatePairs; + UStringVector newNames; + int curIndex = 0; - UINT32 numItemsInArchive; + UInt32 numItemsInArchive; RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive)); for (UInt32 i = 0; i < numItemsInArchive; i++) { if (curIndex < realIndices.Size()) if (realIndices[curIndex] == i) { - CUpdatePair2 updatePair; - updatePair.NewData = false; - updatePair.NewProperties = true; - updatePair.ExistInArchive = true; - updatePair.ExistOnDisk = false; - RINOK(IsArchiveItemAnti(GetArchive(), i, updatePair.IsAnti)); - updatePair.ArchiveItemIndex = i; - updatePair.NewNameIsDefined = true; - - updatePair.NewName = newItemName; + CUpdatePair2 up2; + up2.NewData = false; + up2.NewProps = true; + RINOK(IsArchiveItemAnti(GetArchive(), i, up2.IsAnti)); + up2.ArcIndex = i; UString oldFullPath; RINOK(GetArchiveItemPath(GetArchive(), i, DefaultName, oldFullPath)); @@ -516,26 +507,25 @@ HRESULT CAgent::RenameItem( if (oldItemPath.CompareNoCase(oldFullPath.Left(oldItemPath.Length())) != 0) return E_INVALIDARG; - updatePair.NewName = newItemPath + oldFullPath.Mid(oldItemPath.Length()); - updatePairs.Add(updatePair); + up2.NewNameIndex = newNames.Add(newItemPath + oldFullPath.Mid(oldItemPath.Length())); + updatePairs.Add(up2); curIndex++; continue; } - CUpdatePair2 updatePair; - updatePair.NewData = updatePair.NewProperties = false; - updatePair.ExistInArchive = true; - updatePair.ExistOnDisk = false; - updatePair.IsAnti = false; - updatePair.ArchiveItemIndex = i; - updatePairs.Add(updatePair); + CUpdatePair2 up2; + up2.NewData = up2.NewProps = false; + up2.IsAnti = false; + up2.ArcIndex = i; + updatePairs.Add(up2); } updateCallbackSpec->Callback = &updateCallbackAgent; updateCallbackSpec->UpdatePairs = &updatePairs; + updateCallbackSpec->NewNames = &newNames; updateCallbackSpec->Archive = GetArchive(); return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback); } -STDMETHODIMP CAgent::SetProperties(const wchar_t **names, +STDMETHODIMP CAgent::SetProperties(const wchar_t **names, const PROPVARIANT *values, INT32 numProperties) { m_PropNames.Clear(); diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp index a50a26c7..704b5d33 100755 --- a/CPP/7zip/UI/Agent/AgentProxy.cpp +++ b/CPP/7zip/UI/Agent/AgentProxy.cpp @@ -80,7 +80,7 @@ void CProxyFolder::Clear() Files.Clear(); } -void CProxyFolder::GetPathParts(UStringVector &pathParts) const +void CProxyFolder::GetPathParts(UStringVector &pathParts) const { pathParts.Clear(); UString result; @@ -92,7 +92,7 @@ void CProxyFolder::GetPathParts(UStringVector &pathParts) const } } -UString CProxyFolder::GetFullPathPrefix() const +UString CProxyFolder::GetFullPathPrefix() const { UString result; const CProxyFolder *current = this; @@ -104,7 +104,7 @@ UString CProxyFolder::GetFullPathPrefix() const return result; } -UString CProxyFolder::GetItemName(UInt32 index) const +UString CProxyFolder::GetItemName(UInt32 index) const { if (index < (UInt32)Folders.Size()) return Folders[index].Name; @@ -146,8 +146,8 @@ HRESULT CProxyArchive::Reload(IInArchive *archive, IProgress *progress) return ReadObjects(archive, progress); } -HRESULT CProxyArchive::Load(IInArchive *archive, - const UString &defaultName, +HRESULT CProxyArchive::Load(IInArchive *archive, + const UString &defaultName, // const FILETIME &defaultTime, // UInt32 defaultAttributes, IProgress *progress) @@ -179,7 +179,7 @@ void CProxyFolder::CalculateSizes(IInArchive *archive) { UInt32 index = Files[i].Index; Size += GetSize(archive, index, kpidSize); - PackSize += GetSize(archive, index, kpidPackedSize); + PackSize += GetSize(archive, index, kpidPackSize); { NCOM::CPropVariant prop; if (archive->GetProperty(index, kpidCRC, &prop) == S_OK) @@ -213,14 +213,14 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archive, IProgress *progress) RINOK(archive->GetNumberOfItems(&numItems)); if (progress != NULL) { - UINT64 totalItems = numItems; + UINT64 totalItems = numItems; RINOK(progress->SetTotal(totalItems)); } for(UInt32 i = 0; i < numItems; i++) { if (progress != NULL) { - UINT64 currentItemIndex = i; + UINT64 currentItemIndex = i; RINOK(progress->SetCompleted(¤tItemIndex)); } NCOM::CPropVariant propVariantPath; diff --git a/CPP/7zip/UI/Agent/AgentProxy.h b/CPP/7zip/UI/Agent/AgentProxy.h index 5cf7a05b..a0111088 100755 --- a/CPP/7zip/UI/Agent/AgentProxy.h +++ b/CPP/7zip/UI/Agent/AgentProxy.h @@ -53,7 +53,7 @@ public: // UInt32 DefaultAttributes; CProxyFolder RootFolder; HRESULT Reload(IInArchive *archive, IProgress *progress); - HRESULT Load(IInArchive *archive, + HRESULT Load(IInArchive *archive, const UString &defaultName, // const FILETIME &defaultTime, // UInt32 defaultAttributes, diff --git a/CPP/7zip/UI/Agent/ArchiveFolder.cpp b/CPP/7zip/UI/Agent/ArchiveFolder.cpp index 3baa6202..780d26b8 100755 --- a/CPP/7zip/UI/Agent/ArchiveFolder.cpp +++ b/CPP/7zip/UI/Agent/ArchiveFolder.cpp @@ -19,11 +19,11 @@ using namespace NWindows; using namespace NCOM; -STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems, +STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems, const wchar_t *path, IFolderOperationsExtractCallback *callback) { COM_TRY_BEGIN - CArchiveExtractCallback *extractCallbackSpec = new + CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback; CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec; UStringVector pathParts; @@ -41,31 +41,31 @@ STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems, IID_IFolderArchiveExtractCallback, &extractCallback2)); } - NExtract::NPathMode::EEnum pathMode = _flatMode ? + NExtract::NPathMode::EEnum pathMode = _flatMode ? NExtract::NPathMode::kNoPathnames : NExtract::NPathMode::kCurrentPathnames; extractCallbackSpec->InitForMulti(false, pathMode, NExtract::NOverwriteMode::kAskBefore); - extractCallbackSpec->Init(_agentSpec->GetArchive(), - extractCallback2, + extractCallbackSpec->Init(_agentSpec->GetArchive(), + extractCallback2, false, path, - pathParts, + pathParts, _agentSpec->DefaultName, - _agentSpec->DefaultTime, - _agentSpec->DefaultAttributes, + _agentSpec->DefaultTime, + _agentSpec->DefaultAttrib, (UInt64)(Int64)-1 // ,_agentSpec->_srcDirectoryPrefix ); CUIntVector realIndices; GetRealIndices(indices, numItems, realIndices); - return _agentSpec->GetArchive()->Extract(&realIndices.Front(), + return _agentSpec->GetArchive()->Extract(&realIndices.Front(), realIndices.Size(), BoolToInt(false), extractCallback); COM_TRY_END } -STDMETHODIMP CAgentFolder::MoveTo(const UINT32 * /* indices */, UINT32 /* numItems */, +STDMETHODIMP CAgentFolder::MoveTo(const UINT32 * /* indices */, UINT32 /* numItems */, const wchar_t * /* path */, IFolderOperationsExtractCallback * /* callback */) { return E_NOTIMPL; diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp index 5f62dc9c..d983c13a 100755 --- a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp +++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp @@ -28,7 +28,7 @@ int CArchiveFolderManager::FindFormat(const UString &type) return -1; } -STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath, +STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath, IFolderFolder **resultFolder, IProgress *progress) { CMyComPtr<IArchiveOpenCallback> openArchiveCallback; @@ -122,7 +122,7 @@ STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types) *types = valueTemp.Detach(); return S_OK; } -STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type, +STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type, const wchar_t * filePath, IProgress progress) { return E_NOTIMPL; diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp index 6bf41d61..304dce83 100755 --- a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp +++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp @@ -27,7 +27,7 @@ HRESULT CAgentFolder::CommonUpdateOperation( bool deleteOperation, bool createFolderOperation, bool renameOperation, - const wchar_t *newItemName, + const wchar_t *newItemName, const NUpdateArchive::CActionSet *actionSet, const UINT32 *indices, UINT32 numItems, IFolderArchiveUpdateCallback *updateCallback100) @@ -67,8 +67,8 @@ HRESULT CAgentFolder::CommonUpdateOperation( { result = _agentSpec->RenameItem( tempFileName, - indices, numItems, - newItemName, + indices, numItems, + newItemName, updateCallback100); } else @@ -92,8 +92,15 @@ HRESULT CAgentFolder::CommonUpdateOperation( tempFile.DisableDeleting(); if (!MyMoveFile(tempFileName, archiveFilePath )) return GetLastError(); - - RINOK(_agentSpec->ReOpen(NULL)); + + { + CMyComPtr<IArchiveOpenCallback> openCallback; + if (updateCallback100) + { + RINOK(updateCallback100->QueryInterface(IID_IArchiveOpenCallback, (void **)&openCallback)); + } + RINOK(_agentSpec->ReOpen(openCallback)); + } //////////////////////////// // Restore FolderItem; @@ -136,7 +143,7 @@ STDMETHODIMP CAgentFolder::CopyFrom( RINOK(progressWrapper.QueryInterface( IID_IFolderArchiveUpdateCallback, &updateCallback100)); } - return CommonUpdateOperation(false, false, false, NULL, + return CommonUpdateOperation(false, false, false, NULL, &NUpdateArchive::kAddActionSet, 0, 0, updateCallback100); COM_TRY_END } @@ -152,7 +159,7 @@ STDMETHODIMP CAgentFolder::Delete(const UINT32 *indices, UINT32 numItems, IProgr RINOK(progressWrapper.QueryInterface( IID_IFolderArchiveUpdateCallback, &updateCallback100)); } - return CommonUpdateOperation(true, false, false, NULL, + return CommonUpdateOperation(true, false, false, NULL, &NUpdateArchive::kDeleteActionSet, indices, numItems, updateCallback100); COM_TRY_END } @@ -185,7 +192,7 @@ STDMETHODIMP CAgentFolder::Rename(UINT32 index, const wchar_t *newName, IProgres CMyComPtr<IProgress> progressWrapper = progress; RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100)); } - return CommonUpdateOperation(false, false, true, newName, NULL, &indices.Front(), + return CommonUpdateOperation(false, false, true, newName, NULL, &indices.Front(), indices.Size(), updateCallback100); COM_TRY_END } @@ -195,7 +202,7 @@ STDMETHODIMP CAgentFolder::CreateFile(const wchar_t * /* name */, IProgress * /* return E_NOTIMPL; } -STDMETHODIMP CAgentFolder::SetProperty(UINT32 /* index */, PROPID /* propID */, +STDMETHODIMP CAgentFolder::SetProperty(UINT32 /* index */, PROPID /* propID */, const PROPVARIANT * /* value */, IProgress * /* progress */) { return E_NOTIMPL; diff --git a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp index e00d837a..6f435b35 100755 --- a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp +++ b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp @@ -63,9 +63,9 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const wchar_t *name, DWORD systemErr if (Callback) { RINOK(Callback->UpdateErrorMessage( - UString(L"WARNING: ") + - NError::MyFormatMessageW(systemError) + - UString(L": ") + + UString(L"WARNING: ") + + NError::MyFormatMessageW(systemError) + + UString(L": ") + UString(name))); return S_FALSE; } |