This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -12,7 +12,7 @@
#include "../../../Windows/FileName.h"
#include "../../../Windows/PropVariantConv.h"
#ifndef _7ZIP_ST
#ifndef Z7_ST
#include "../../../Windows/Synchronization.h"
#endif
@@ -29,8 +29,12 @@ static const bool k_keepEmptyDirPrefixes =
false; // 22.00
// true; // 21.07
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
extern
CExternalCodecs g_ExternalCodecs;
CExternalCodecs g_ExternalCodecs;
extern
const CExternalCodecs *g_ExternalCodecs_Ptr;
const CExternalCodecs *g_ExternalCodecs_Ptr;
static CCodecs::CReleaser g_CodecsReleaser;
#else
@@ -39,7 +43,7 @@ static const bool k_keepEmptyDirPrefixes =
CMyComPtr<IUnknown> g_CodecsRef;
#endif
#ifndef _7ZIP_ST
#ifndef Z7_ST
static NSynchronization::CCriticalSection g_CriticalSection;
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
#else
@@ -50,7 +54,7 @@ void FreeGlobalCodecs()
{
MT_LOCK
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
if (g_CodecsObj)
{
g_CodecsObj->CloseLibs();
@@ -73,7 +77,7 @@ HRESULT LoadGlobalCodecs()
g_CodecsObj = new CCodecs;
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
g_ExternalCodecs.GetCodecs = g_CodecsObj;
g_ExternalCodecs.GetHashers = g_CodecsObj;
g_CodecsReleaser.Set(g_CodecsObj);
@@ -82,7 +86,7 @@ HRESULT LoadGlobalCodecs()
g_CodecsRef = g_CodecsObj;
#endif
RINOK(g_CodecsObj->Load());
RINOK(g_CodecsObj->Load())
if (g_CodecsObj->Formats.IsEmpty())
{
FreeGlobalCodecs();
@@ -91,15 +95,15 @@ HRESULT LoadGlobalCodecs()
Codecs_AddHashArcHandler(g_CodecsObj);
#ifdef EXTERNAL_CODECS
RINOK(g_ExternalCodecs.Load());
#ifdef Z7_EXTERNAL_CODECS
RINOK(g_ExternalCodecs.Load())
g_ExternalCodecs_Ptr = &g_ExternalCodecs;
#endif
return S_OK;
}
STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
Z7_COM7F_IMF(CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder))
{
*agentFolder = this;
return S_OK;
@@ -119,9 +123,9 @@ void CAgentFolder::LoadFolder(unsigned proxyDirIndex)
_items.Add(item);
const CProxyFile2 &file = _proxy2->Files[dir.Items[i]];
if (file.DirIndex != -1)
LoadFolder(file.DirIndex);
LoadFolder((unsigned)file.DirIndex);
if (_loadAltStreams && file.AltDirIndex != -1)
LoadFolder(file.AltDirIndex);
LoadFolder((unsigned)file.AltDirIndex);
}
return;
}
@@ -143,7 +147,7 @@ void CAgentFolder::LoadFolder(unsigned proxyDirIndex)
}
}
STDMETHODIMP CAgentFolder::LoadItems()
Z7_COM7F_IMF(CAgentFolder::LoadItems())
{
if (!_agentSpec->_archiveLink.IsOpen)
return E_FAIL;
@@ -160,7 +164,7 @@ STDMETHODIMP CAgentFolder::LoadItems()
return S_OK;
}
STDMETHODIMP CAgentFolder::GetNumberOfItems(UInt32 *numItems)
Z7_COM7F_IMF(CAgentFolder::GetNumberOfItems(UInt32 *numItems))
{
if (_flatMode)
*numItems = _items.Size();
@@ -217,7 +221,7 @@ void CAgentFolder::GetPrefix(UInt32 index, UString &prefix) const
{
const CProxyFile2 &file = _proxy2->Files[(unsigned)_proxy2->Dirs[proxyIndex].ArcIndex];
len += file.NameLen + 1;
proxyIndex = (file.Parent == -1) ? 0 : _proxy2->Files[(unsigned)file.Parent].GetDirIndex(file.IsAltStream);
proxyIndex = (file.Parent == -1) ? 0 : (unsigned)_proxy2->Files[(unsigned)file.Parent].GetDirIndex(file.IsAltStream);
}
wchar_t *p = prefix.GetBuf_SetEnd(len) + len;
@@ -229,7 +233,7 @@ void CAgentFolder::GetPrefix(UInt32 index, UString &prefix) const
*p = WCHAR_PATH_SEPARATOR;
p -= file.NameLen;
wmemcpy(p, file.Name, file.NameLen);
proxyIndex = (file.Parent == -1) ? 0 : _proxy2->Files[(unsigned)file.Parent].GetDirIndex(file.IsAltStream);
proxyIndex = (file.Parent == -1) ? 0 : (unsigned)_proxy2->Files[(unsigned)file.Parent].GetDirIndex(file.IsAltStream);
}
}
else
@@ -239,7 +243,7 @@ void CAgentFolder::GetPrefix(UInt32 index, UString &prefix) const
{
const CProxyDir *dir = &_proxy->Dirs[proxyIndex];
len += dir->NameLen + 1;
proxyIndex = dir->ParentDir;
proxyIndex = (unsigned)dir->ParentDir;
}
wchar_t *p = prefix.GetBuf_SetEnd(len) + len;
@@ -251,14 +255,14 @@ void CAgentFolder::GetPrefix(UInt32 index, UString &prefix) const
*p = WCHAR_PATH_SEPARATOR;
p -= dir->NameLen;
wmemcpy(p, dir->Name, dir->NameLen);
proxyIndex = dir->ParentDir;
proxyIndex = (unsigned)dir->ParentDir;
}
}
}
UString CAgentFolder::GetFullPrefix(UInt32 index) const
{
int foldIndex = _proxyDirIndex;
unsigned foldIndex = _proxyDirIndex;
if (_flatMode)
foldIndex = _items[index].DirIndex;
@@ -269,7 +273,7 @@ UString CAgentFolder::GetFullPrefix(UInt32 index) const
return _proxy->GetDirPath_as_Prefix(foldIndex);
}
STDMETHODIMP_(UInt64) CAgentFolder::GetItemSize(UInt32 index)
Z7_COM7F_IMF2(UInt64, CAgentFolder::GetItemSize(UInt32 index))
{
unsigned arcIndex;
if (_proxy2)
@@ -294,7 +298,7 @@ STDMETHODIMP_(UInt64) CAgentFolder::GetItemSize(UInt32 index)
return item.Size;
if (!item.IsLeaf())
return 0;
arcIndex = item.ArcIndex;
arcIndex = (unsigned)item.ArcIndex;
}
else
{
@@ -309,7 +313,7 @@ STDMETHODIMP_(UInt64) CAgentFolder::GetItemSize(UInt32 index)
return 0;
}
STDMETHODIMP CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
Z7_COM7F_IMF(CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value))
{
COM_TRY_BEGIN
NCOM::CPropVariant prop;
@@ -363,7 +367,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT
// if (itemFolder.IsLeaf)
if (!item.Ignore)
{
RINOK(_agentSpec->GetArchive()->GetProperty(arcIndex, propID, value));
RINOK(_agentSpec->GetArchive()->GetProperty(arcIndex, propID, value))
}
if (itemFolder.CrcIsDefined && value->vt == VT_EMPTY)
prop = itemFolder.Crc;
@@ -397,7 +401,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT
{
if (item.IsLeaf())
{
RINOK(_agentSpec->GetArchive()->GetProperty(item.ArcIndex, propID, value));
RINOK(_agentSpec->GetArchive()->GetProperty((unsigned)item.ArcIndex, propID, value))
}
if (item.CrcIsDefined && value->vt == VT_EMPTY)
prop = item.Crc;
@@ -405,7 +409,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT
}
default:
if (item.IsLeaf())
return _agentSpec->GetArchive()->GetProperty(item.ArcIndex, propID, value);
return _agentSpec->GetArchive()->GetProperty((unsigned)item.ArcIndex, propID, value);
}
}
else
@@ -436,7 +440,7 @@ static UInt64 GetUInt64Prop(IInArchive *archive, UInt32 index, PROPID propID)
return 0;
}
STDMETHODIMP CAgentFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len)
Z7_COM7F_IMF(CAgentFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len))
{
if (_proxy2)
{
@@ -467,9 +471,9 @@ STDMETHODIMP CAgentFolder::GetItemName(UInt32 index, const wchar_t **name, unsig
}
}
STDMETHODIMP CAgentFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len)
Z7_COM7F_IMF(CAgentFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len))
{
*name = 0;
*name = NULL;
*len = 0;
if (!_flatMode)
return S_OK;
@@ -493,7 +497,7 @@ STDMETHODIMP CAgentFolder::GetItemPrefix(UInt32 index, const wchar_t **name, uns
return S_OK;
}
static int CompareRawProps(IArchiveGetRawProps *rawProps, int arcIndex1, int arcIndex2, PROPID propID)
static int CompareRawProps(IArchiveGetRawProps *rawProps, unsigned arcIndex1, unsigned arcIndex2, PROPID propID)
{
// if (propID == kpidSha1)
if (rawProps)
@@ -501,14 +505,14 @@ static int CompareRawProps(IArchiveGetRawProps *rawProps, int arcIndex1, int arc
const void *p1, *p2;
UInt32 size1, size2;
UInt32 propType1, propType2;
HRESULT res1 = rawProps->GetRawProp(arcIndex1, propID, &p1, &size1, &propType1);
HRESULT res2 = rawProps->GetRawProp(arcIndex2, propID, &p2, &size2, &propType2);
const HRESULT res1 = rawProps->GetRawProp(arcIndex1, propID, &p1, &size1, &propType1);
const HRESULT res2 = rawProps->GetRawProp(arcIndex2, propID, &p2, &size2, &propType2);
if (res1 == S_OK && res2 == S_OK)
{
for (UInt32 i = 0; i < size1 && i < size2; i++)
{
Byte b1 = ((const Byte *)p1)[i];
Byte b2 = ((const Byte *)p2)[i];
const Byte b1 = ((const Byte *)p1)[i];
const Byte b2 = ((const Byte *)p2)[i];
if (b1 < b2) return -1;
if (b1 > b2) return 1;
}
@@ -681,7 +685,7 @@ int CAgentFolder::CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int
}
STDMETHODIMP_(Int32) CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw)
Z7_COM7F_IMF2(Int32, CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw))
{
try {
if (_proxy2)
@@ -725,7 +729,7 @@ STDMETHODIMP_(Int32) CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PR
if (realIndex1 < dir1->SubDirs.Size())
{
proxFolder1 = &_proxy->Dirs[dir1->SubDirs[realIndex1]];
arcIndex1 = proxFolder1->ArcIndex;
arcIndex1 = (unsigned)proxFolder1->ArcIndex;
}
else
arcIndex1 = dir1->SubFiles[realIndex1 - dir1->SubDirs.Size()];
@@ -733,7 +737,7 @@ STDMETHODIMP_(Int32) CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PR
if (realIndex2 < dir2->SubDirs.Size())
{
proxFolder2 = &_proxy->Dirs[dir2->SubDirs[realIndex2]];
arcIndex2 = proxFolder2->ArcIndex;
arcIndex2 = (unsigned)proxFolder2->ArcIndex;
}
else
arcIndex2 = dir2->SubFiles[realIndex2 - dir2->SubDirs.Size()];
@@ -866,17 +870,17 @@ HRESULT CAgentFolder::BindToFolder_Internal(unsigned proxyDirIndex, IFolderFolde
return S_OK;
}
STDMETHODIMP CAgentFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
Z7_COM7F_IMF(CAgentFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder))
{
COM_TRY_BEGIN
if (_proxy2)
{
SET_realIndex_AND_dir_2
unsigned arcIndex = dir->Items[realIndex];
const unsigned arcIndex = dir->Items[realIndex];
const CProxyFile2 &item = _proxy2->Files[arcIndex];
if (!item.IsDir())
return E_INVALIDARG;
return BindToFolder_Internal(item.DirIndex, resultFolder);
return BindToFolder_Internal((unsigned)item.DirIndex, resultFolder);
}
SET_realIndex_AND_dir
if (realIndex >= (UInt32)dir->SubDirs.Size())
@@ -885,20 +889,20 @@ STDMETHODIMP CAgentFolder::BindToFolder(UInt32 index, IFolderFolder **resultFold
COM_TRY_END
}
STDMETHODIMP CAgentFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
Z7_COM7F_IMF(CAgentFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder))
{
COM_TRY_BEGIN
if (_proxy2)
{
int index = _proxy2->FindItem(_proxyDirIndex, name, true);
const int index = _proxy2->FindItem(_proxyDirIndex, name, true);
if (index == -1)
return E_INVALIDARG;
return BindToFolder_Internal(_proxy2->Files[_proxy2->Dirs[_proxyDirIndex].Items[index]].DirIndex, resultFolder);
return BindToFolder_Internal((unsigned)_proxy2->Files[_proxy2->Dirs[_proxyDirIndex].Items[index]].DirIndex, resultFolder);
}
int index = _proxy->FindSubDir(_proxyDirIndex, name);
const int index = _proxy->FindSubDir(_proxyDirIndex, name);
if (index == -1)
return E_INVALIDARG;
return BindToFolder_Internal(index, resultFolder);
return BindToFolder_Internal((unsigned)index, resultFolder);
COM_TRY_END
}
@@ -933,7 +937,7 @@ HRESULT CAgentFolder::BindToAltStreams_Internal(unsigned proxyDirIndex, IFolderF
return S_OK;
}
STDMETHODIMP CAgentFolder::BindToAltStreams(UInt32 index, IFolderFolder **resultFolder)
Z7_COM7F_IMF(CAgentFolder::BindToAltStreams(UInt32 index, IFolderFolder **resultFolder))
{
COM_TRY_BEGIN
@@ -958,11 +962,11 @@ STDMETHODIMP CAgentFolder::BindToAltStreams(UInt32 index, IFolderFolder **result
}
else
{
unsigned arcIndex = _proxy2->Dirs[_proxyDirIndex].ArcIndex;
const unsigned arcIndex = (unsigned)_proxy2->Dirs[_proxyDirIndex].ArcIndex;
const CProxyFile2 &item = _proxy2->Files[arcIndex];
if (item.AltDirIndex == -1)
return S_OK;
altDirIndex = item.AltDirIndex;
altDirIndex = (unsigned)item.AltDirIndex;
// parentFolder = _parentFolder;
}
@@ -974,17 +978,17 @@ STDMETHODIMP CAgentFolder::BindToAltStreams(UInt32 index, IFolderFolder **result
}
SET_realIndex_AND_dir_2
unsigned arcIndex = dir->Items[realIndex];
const unsigned arcIndex = dir->Items[realIndex];
const CProxyFile2 &item = _proxy2->Files[arcIndex];
if (item.AltDirIndex == -1)
return S_OK;
return BindToAltStreams_Internal(item.AltDirIndex, resultFolder);
return BindToAltStreams_Internal((unsigned)item.AltDirIndex, resultFolder);
}
COM_TRY_END
}
STDMETHODIMP CAgentFolder::BindToAltStreams(const wchar_t *name, IFolderFolder **resultFolder)
Z7_COM7F_IMF(CAgentFolder::BindToAltStreams(const wchar_t *name, IFolderFolder **resultFolder))
{
COM_TRY_BEGIN
@@ -1006,14 +1010,14 @@ STDMETHODIMP CAgentFolder::BindToAltStreams(const wchar_t *name, IFolderFolder *
const CProxyFile2 &file = _proxy2->Files[dir.Items[i]];
if (file.AltDirIndex != -1)
if (CompareFileNames(file.Name, name) == 0)
return BindToAltStreams_Internal(file.AltDirIndex, resultFolder);
return BindToAltStreams_Internal((unsigned)file.AltDirIndex, resultFolder);
}
return E_INVALIDARG;
}
COM_TRY_END
}
STDMETHODIMP CAgentFolder::AreAltStreamsSupported(UInt32 index, Int32 *isSupported)
Z7_COM7F_IMF(CAgentFolder::AreAltStreamsSupported(UInt32 index, Int32 *isSupported))
{
*isSupported = BoolToInt(false);
@@ -1032,7 +1036,7 @@ STDMETHODIMP CAgentFolder::AreAltStreamsSupported(UInt32 index, Int32 *isSupport
*isSupported = BoolToInt(true);
return S_OK;
}
arcIndex = _proxy2->Dirs[_proxyDirIndex].ArcIndex;
arcIndex = (unsigned)_proxy2->Dirs[_proxyDirIndex].ArcIndex;
}
else
{
@@ -1046,7 +1050,7 @@ STDMETHODIMP CAgentFolder::AreAltStreamsSupported(UInt32 index, Int32 *isSupport
}
STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
Z7_COM7F_IMF(CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder))
{
COM_TRY_BEGIN
/*
@@ -1071,15 +1075,15 @@ STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
if (parentIndex == -1)
proxyDirIndex = k_Proxy2_RootDirIndex;
else
proxyDirIndex = _proxy2->Files[(unsigned)parentIndex].DirIndex;
proxyDirIndex = (unsigned)_proxy2->Files[(unsigned)parentIndex].DirIndex;
}
}
else
{
int parent = _proxy->Dirs[_proxyDirIndex].ParentDir;
const int parent = _proxy->Dirs[_proxyDirIndex].ParentDir;
if (parent == -1)
return S_OK;
proxyDirIndex = parent;
proxyDirIndex = (unsigned)parent;
}
CAgentFolder *folderSpec = new CAgentFolder;
@@ -1091,10 +1095,11 @@ STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
COM_TRY_END
}
STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
Z7_COM7F_IMF(CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream))
{
CMyComPtr<IInArchiveGetStream> getStream;
_agentSpec->GetArchive()->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream);
Z7_DECL_CMyComPtr_QI_FROM(
IInArchiveGetStream,
getStream, _agentSpec->GetArchive())
if (!getStream)
return S_OK;
@@ -1113,7 +1118,7 @@ STDMETHODIMP CAgentFolder::GetStream(UInt32 index, ISequentialInStream **stream)
const CProxyDir &item = _proxy->Dirs[dir->SubDirs[realIndex]];
if (!item.IsLeaf())
return S_OK;
arcIndex = item.ArcIndex;
arcIndex = (unsigned)item.ArcIndex;
}
else
arcIndex = dir->SubFiles[realIndex - dir->SubDirs.Size()];
@@ -1139,11 +1144,11 @@ struct CArchiveItemPropertyTemp
VARTYPE Type;
};
STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProps)
Z7_COM7F_IMF(CAgentFolder::GetNumberOfProperties(UInt32 *numProps))
{
COM_TRY_BEGIN
RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProps));
*numProps += ARRAY_SIZE(kProps);
RINOK(_agentSpec->GetArchive()->GetNumberOfProperties(numProps))
*numProps += Z7_ARRAY_SIZE(kProps);
if (!_flatMode)
(*numProps)--;
/*
@@ -1164,7 +1169,7 @@ STDMETHODIMP CAgentFolder::GetNumberOfProperties(UInt32 *numProps)
COM_TRY_END
}
STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
Z7_COM7F_IMF(CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType))
{
COM_TRY_BEGIN
UInt32 numProps;
@@ -1182,7 +1187,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
{
*propID = kpidName;
*varType = VT_BSTR;
*name = 0;
*name = NULL;
return S_OK;
}
index--;
@@ -1190,7 +1195,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
if (index < numProps)
{
RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType));
RINOK(_agentSpec->GetArchive()->GetPropertyInfo(index, name, propID, varType))
if (*propID == kpidPath)
*propID = kpidName;
}
@@ -1206,7 +1211,7 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
*/
*propID = kProps[index];
*varType = k7z_PROPID_To_VARTYPE[(unsigned)*propID];
*name = 0;
*name = NULL;
}
return S_OK;
COM_TRY_END
@@ -1221,7 +1226,7 @@ static const PROPID kFolderProps[] =
kpidCRC
};
STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
Z7_COM7F_IMF(CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value))
{
COM_TRY_BEGIN
@@ -1284,21 +1289,23 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
COM_TRY_END
}
STDMETHODIMP CAgentFolder::GetNumberOfFolderProperties(UInt32 *numProps)
Z7_COM7F_IMF(CAgentFolder::GetNumberOfFolderProperties(UInt32 *numProps))
{
*numProps = ARRAY_SIZE(kFolderProps);
*numProps = Z7_ARRAY_SIZE(kFolderProps);
return S_OK;
}
STDMETHODIMP CAgentFolder::GetFolderPropertyInfo IMP_IFolderFolder_GetProp(kFolderProps)
IMP_IFolderFolder_GetProp(
CAgentFolder::GetFolderPropertyInfo,
kFolderProps)
STDMETHODIMP CAgentFolder::GetParent(UInt32 /* index */, UInt32 * /* parent */, UInt32 * /* parentType */)
Z7_COM7F_IMF(CAgentFolder::GetParent(UInt32 /* index */, UInt32 * /* parent */, UInt32 * /* parentType */))
{
return E_FAIL;
}
STDMETHODIMP CAgentFolder::GetNumRawProps(UInt32 *numProps)
Z7_COM7F_IMF(CAgentFolder::GetNumRawProps(UInt32 *numProps))
{
IArchiveGetRawProps *rawProps = _agentSpec->_archiveLink.GetArchiveGetRawProps();
if (rawProps)
@@ -1307,7 +1314,7 @@ STDMETHODIMP CAgentFolder::GetNumRawProps(UInt32 *numProps)
return S_OK;
}
STDMETHODIMP CAgentFolder::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID)
Z7_COM7F_IMF(CAgentFolder::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID))
{
IArchiveGetRawProps *rawProps = _agentSpec->_archiveLink.GetArchiveGetRawProps();
if (rawProps)
@@ -1315,7 +1322,7 @@ STDMETHODIMP CAgentFolder::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *prop
return E_FAIL;
}
STDMETHODIMP CAgentFolder::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
Z7_COM7F_IMF(CAgentFolder::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType))
{
IArchiveGetRawProps *rawProps = _agentSpec->_archiveLink.GetArchiveGetRawProps();
if (rawProps)
@@ -1339,7 +1346,7 @@ STDMETHODIMP CAgentFolder::GetRawProp(UInt32 index, PROPID propID, const void **
*propType = 0;
return S_OK;
}
arcIndex = item.ArcIndex;
arcIndex = (unsigned)item.ArcIndex;
}
else
arcIndex = dir->SubFiles[realIndex - dir->SubDirs.Size()];
@@ -1352,29 +1359,27 @@ STDMETHODIMP CAgentFolder::GetRawProp(UInt32 index, PROPID propID, const void **
return S_OK;
}
STDMETHODIMP CAgentFolder::GetFolderArcProps(IFolderArcProps **object)
Z7_COM7F_IMF(CAgentFolder::GetFolderArcProps(IFolderArcProps **object))
{
CMyComPtr<IFolderArcProps> temp = _agentSpec;
*object = temp.Detach();
return S_OK;
}
#ifdef NEW_FOLDER_INTERFACE
STDMETHODIMP CAgentFolder::SetFlatMode(Int32 flatMode)
Z7_COM7F_IMF(CAgentFolder::SetFlatMode(Int32 flatMode))
{
_flatMode = IntToBool(flatMode);
return S_OK;
}
#endif
int CAgentFolder::GetRealIndex(unsigned index) const
{
if (!_flatMode)
{
if (_proxy2)
return _proxy2->GetRealIndex(_proxyDirIndex, index);
return (int)_proxy2->GetRealIndex(_proxyDirIndex, index);
else
return _proxy->GetRealIndex(_proxyDirIndex, index);
}
@@ -1383,12 +1388,12 @@ int CAgentFolder::GetRealIndex(unsigned index) const
if (_proxy2)
{
const CProxyDir2 *dir = &_proxy2->Dirs[item.DirIndex];
return dir->Items[item.Index];
return (int)dir->Items[item.Index];
}
else
{
const CProxyDir *dir = &_proxy->Dirs[item.DirIndex];
unsigned realIndex = item.Index;
const unsigned realIndex = item.Index;
if (realIndex < dir->SubDirs.Size())
{
const CProxyDir &f = _proxy->Dirs[dir->SubDirs[realIndex]];
@@ -1396,7 +1401,7 @@ int CAgentFolder::GetRealIndex(unsigned index) const
return -1;
return f.ArcIndex;
}
return dir->SubFiles[realIndex - dir->SubDirs.Size()];
return (int)dir->SubFiles[realIndex - dir->SubDirs.Size()];
}
}
}
@@ -1437,7 +1442,7 @@ void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, bool i
const CProxyDir &f = _proxy->Dirs[dir->SubDirs[realIndex]];
if (!f.IsLeaf())
continue;
arcIndex = f.ArcIndex;
arcIndex = (unsigned)f.ArcIndex;
}
else
arcIndex = dir->SubFiles[realIndex - dir->SubDirs.Size()];
@@ -1448,7 +1453,7 @@ void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, bool i
HeapSort(&realIndices.Front(), realIndices.Size());
}
STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
Z7_COM7F_IMF(CAgentFolder::Extract(const UInt32 *indices,
UInt32 numItems,
Int32 includeAltStreams,
Int32 replaceAltStreamColon,
@@ -1456,7 +1461,7 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
Int32 testMode,
IFolderArchiveExtractCallback *extractCallback2)
IFolderArchiveExtractCallback *extractCallback2))
{
COM_TRY_BEGIN
@@ -1492,6 +1497,7 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
{
pathU = us2fs(path);
if (!pathU.IsEmpty())
if (!NFile::NName::IsAltStreamPrefixWithColon(pathU))
{
NFile::NName::NormalizeDirPathPrefix(pathU);
NFile::NDir::CreateComplexDir(pathU);
@@ -1524,7 +1530,7 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
(UInt64)(Int64)-1);
if (_proxy2)
extractCallbackSpec->SetBaseParentFolderIndex(_proxy2->Dirs[_proxyDirIndex].ArcIndex);
extractCallbackSpec->SetBaseParentFolderIndex((unsigned)_proxy2->Dirs[_proxyDirIndex].ArcIndex);
// do we need another base folder for subfolders ?
extractCallbackSpec->DirPathPrefix_for_HashFiles = _agentSpec->_hashBaseFolderPrefix;
@@ -1538,7 +1544,7 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
if (!testMode)
{
RINOK(extractCallbackSpec->PrepareHardLinks(&realIndices));
RINOK(extractCallbackSpec->PrepareHardLinks(&realIndices))
}
#endif
@@ -1592,12 +1598,12 @@ bool CAgent::CanUpdate() const
return true;
}
STDMETHODIMP CAgent::Open(
Z7_COM7F_IMF(CAgent::Open(
IInStream *inStream,
const wchar_t *filePath,
const wchar_t *arcFormat,
BSTR *archiveType,
IArchiveOpenCallback *openArchiveCallback)
IArchiveOpenCallback *openArchiveCallback))
{
COM_TRY_BEGIN
_archiveFilePath = filePath;
@@ -1609,7 +1615,7 @@ STDMETHODIMP CAgent::Open(
if (!inStream)
{
if (!fi.Find(us2fs(_archiveFilePath)))
return ::GetLastError();
return GetLastError_noZero_HRESULT();
if (fi.IsDir())
return E_FAIL;
_attrib = fi.Attrib;
@@ -1623,7 +1629,7 @@ STDMETHODIMP CAgent::Open(
}
CArcInfoEx archiverInfo0, archiverInfo1;
RINOK(LoadGlobalCodecs());
RINOK(LoadGlobalCodecs())
CObjectVector<COpenType> types;
if (!ParseOpenTypes(*g_CodecsObj, arcFormat, types))
@@ -1665,7 +1671,7 @@ STDMETHODIMP CAgent::Open(
ArchiveType = GetTypeOfArc(arc);
if (archiveType)
{
RINOK(StringToBstr(ArchiveType, archiveType));
RINOK(StringToBstr(ArchiveType, archiveType))
}
if (arc.IsHashHandler(options))
@@ -1678,7 +1684,7 @@ STDMETHODIMP CAgent::Open(
}
STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback)
Z7_COM7F_IMF(CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback))
{
COM_TRY_BEGIN
if (_proxy2)
@@ -1704,12 +1710,12 @@ STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback)
options.filePath = _archiveFilePath;
options.callback = openArchiveCallback;
RINOK(_archiveLink.ReOpen(options));
RINOK(_archiveLink.ReOpen(options))
return ReadItems();
COM_TRY_END
}
STDMETHODIMP CAgent::Close()
Z7_COM7F_IMF(CAgent::Close())
{
COM_TRY_BEGIN
return _archiveLink.Close();
@@ -1717,7 +1723,7 @@ STDMETHODIMP CAgent::Close()
}
/*
STDMETHODIMP CAgent::EnumProperties(IEnumSTATPROPSTG **EnumProperties)
Z7_COM7F_IMF(CAgent::EnumProperties(IEnumSTATPROPSTG **EnumProperties)
{
return _archive->EnumProperties(EnumProperties);
}
@@ -1748,7 +1754,7 @@ HRESULT CAgent::ReadItems()
CMyComBSTR name;
PROPID propID;
VARTYPE varType;
RINOK(arc.Archive->GetPropertyInfo(i, &name, &propID, &varType));
RINOK(arc.Archive->GetPropertyInfo(i, &name, &propID, &varType))
if (propID == kpidPath)
ThereIsPathProp = true;
/*
@@ -1763,12 +1769,12 @@ HRESULT CAgent::ReadItems()
return _proxy->Load(GetArc(), NULL);
}
STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
Z7_COM7F_IMF(CAgent::BindToRootFolder(IFolderFolder **resultFolder))
{
COM_TRY_BEGIN
if (!_archiveLink.Arcs.IsEmpty())
{
RINOK(ReadItems());
RINOK(ReadItems())
}
CAgentFolder *folderSpec = new CAgentFolder;
CMyComPtr<IFolderFolder> rootFolder = folderSpec;
@@ -1778,12 +1784,12 @@ STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
COM_TRY_END
}
STDMETHODIMP CAgent::Extract(
Z7_COM7F_IMF(CAgent::Extract(
NExtract::NPathMode::EEnum pathMode,
NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
Int32 testMode,
IFolderArchiveExtractCallback *extractCallback2)
IFolderArchiveExtractCallback *extractCallback2))
{
COM_TRY_BEGIN
@@ -1820,40 +1826,40 @@ STDMETHODIMP CAgent::Extract(
if (!testMode)
{
RINOK(extractCallbackSpec->PrepareHardLinks(NULL)); // NULL means all items
RINOK(extractCallbackSpec->PrepareHardLinks(NULL)) // NULL means all items
}
#endif
return GetArchive()->Extract(0, (UInt32)(Int32)-1, testMode, extractCallback);
return GetArchive()->Extract(NULL, (UInt32)(Int32)-1, testMode, extractCallback);
COM_TRY_END
}
STDMETHODIMP CAgent::GetNumberOfProperties(UInt32 *numProps)
Z7_COM7F_IMF(CAgent::GetNumberOfProperties(UInt32 *numProps))
{
COM_TRY_BEGIN
return GetArchive()->GetNumberOfProperties(numProps);
COM_TRY_END
}
STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
Z7_COM7F_IMF(CAgent::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType))
{
COM_TRY_BEGIN
RINOK(GetArchive()->GetPropertyInfo(index, name, propID, varType));
RINOK(GetArchive()->GetPropertyInfo(index, name, propID, varType))
if (*propID == kpidPath)
*propID = kpidName;
return S_OK;
COM_TRY_END
}
STDMETHODIMP CAgent::GetArcNumLevels(UInt32 *numLevels)
Z7_COM7F_IMF(CAgent::GetArcNumLevels(UInt32 *numLevels))
{
*numLevels = _archiveLink.Arcs.Size();
return S_OK;
}
STDMETHODIMP CAgent::GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)
Z7_COM7F_IMF(CAgent::GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value))
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant prop;
@@ -1933,28 +1939,28 @@ STDMETHODIMP CAgent::GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)
COM_TRY_END
}
STDMETHODIMP CAgent::GetArcNumProps(UInt32 level, UInt32 *numProps)
Z7_COM7F_IMF(CAgent::GetArcNumProps(UInt32 level, UInt32 *numProps))
{
return _archiveLink.Arcs[level].Archive->GetNumberOfArchiveProperties(numProps);
}
STDMETHODIMP CAgent::GetArcPropInfo(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
Z7_COM7F_IMF(CAgent::GetArcPropInfo(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType))
{
return _archiveLink.Arcs[level].Archive->GetArchivePropertyInfo(index, name, propID, varType);
}
// MainItemProperty
STDMETHODIMP CAgent::GetArcProp2(UInt32 level, PROPID propID, PROPVARIANT *value)
Z7_COM7F_IMF(CAgent::GetArcProp2(UInt32 level, PROPID propID, PROPVARIANT *value))
{
return _archiveLink.Arcs[level - 1].Archive->GetProperty(_archiveLink.Arcs[level].SubfileIndex, propID, value);
}
STDMETHODIMP CAgent::GetArcNumProps2(UInt32 level, UInt32 *numProps)
Z7_COM7F_IMF(CAgent::GetArcNumProps2(UInt32 level, UInt32 *numProps))
{
return _archiveLink.Arcs[level - 1].Archive->GetNumberOfProperties(numProps);
}
STDMETHODIMP CAgent::GetArcPropInfo2(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)
Z7_COM7F_IMF(CAgent::GetArcPropInfo2(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType))
{
return _archiveLink.Arcs[level - 1].Archive->GetPropertyInfo(index, name, propID, varType);
}

View File

@@ -1,19 +1,17 @@
// Agent/Agent.h
#ifndef __AGENT_AGENT_H
#define __AGENT_AGENT_H
#ifndef ZIP7_INC_AGENT_AGENT_H
#define ZIP7_INC_AGENT_AGENT_H
#include "../../../Common/MyCom.h"
#include "../../../Windows/PropVariant.h"
#include "../Common/LoadCodecs.h"
#include "../Common/OpenArchive.h"
#include "../Common/UpdateAction.h"
#ifdef NEW_FOLDER_INTERFACE
#include "../FileManager/IFolder.h"
#include "../Common/LoadCodecs.h"
#endif
#include "AgentProxy.h"
#include "IFolderArchive.h"
@@ -24,10 +22,13 @@ void FreeGlobalCodecs();
class CAgentFolder;
DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC)
{
STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder) PURE;
};
Z7_PURE_INTERFACES_BEGIN
#define Z7_IFACEM_IArchiveFolderInternal(x) \
x(GetAgentFolder(CAgentFolder **agentFolder))
Z7_IFACE_CONSTR_FOLDERARC(IArchiveFolderInternal, 0xC)
Z7_PURE_INTERFACES_END
struct CProxyItem
{
@@ -47,7 +48,7 @@ enum AGENT_OP
AGENT_OP_Comment
};
class CAgentFolder:
class CAgentFolder Z7_final:
public IFolderFolder,
public IFolderAltStreams,
public IFolderProperties,
@@ -59,65 +60,51 @@ class CAgentFolder:
public IArchiveFolderInternal,
public IInArchiveGetStream,
public IFolderSetZoneIdMode,
#ifdef NEW_FOLDER_INTERFACE
public IFolderOperations,
public IFolderSetFlatMode,
#endif
public CMyUnknownImp
{
void LoadFolder(unsigned proxyDirIndex);
Z7_COM_QI_BEGIN2(IFolderFolder)
Z7_COM_QI_ENTRY(IFolderAltStreams)
Z7_COM_QI_ENTRY(IFolderProperties)
Z7_COM_QI_ENTRY(IArchiveGetRawProps)
Z7_COM_QI_ENTRY(IGetFolderArcProps)
Z7_COM_QI_ENTRY(IFolderCompare)
Z7_COM_QI_ENTRY(IFolderGetItemName)
Z7_COM_QI_ENTRY(IArchiveFolder)
Z7_COM_QI_ENTRY(IArchiveFolderInternal)
Z7_COM_QI_ENTRY(IInArchiveGetStream)
Z7_COM_QI_ENTRY(IFolderSetZoneIdMode)
Z7_COM_QI_ENTRY(IFolderOperations)
Z7_COM_QI_ENTRY(IFolderSetFlatMode)
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_COM7_IMP(IFolderFolder)
Z7_IFACE_COM7_IMP(IFolderAltStreams)
Z7_IFACE_COM7_IMP(IFolderProperties)
Z7_IFACE_COM7_IMP(IArchiveGetRawProps)
Z7_IFACE_COM7_IMP(IGetFolderArcProps)
Z7_IFACE_COM7_IMP(IFolderCompare)
Z7_IFACE_COM7_IMP(IFolderGetItemName)
Z7_IFACE_COM7_IMP(IArchiveFolder)
Z7_IFACE_COM7_IMP(IArchiveFolderInternal)
Z7_IFACE_COM7_IMP(IInArchiveGetStream)
Z7_IFACE_COM7_IMP(IFolderSetZoneIdMode)
Z7_IFACE_COM7_IMP(IFolderOperations)
Z7_IFACE_COM7_IMP(IFolderSetFlatMode)
void LoadFolder(unsigned proxyDirIndex);
public:
MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
MY_QUERYINTERFACE_ENTRY(IFolderAltStreams)
MY_QUERYINTERFACE_ENTRY(IFolderProperties)
MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
MY_QUERYINTERFACE_ENTRY(IGetFolderArcProps)
MY_QUERYINTERFACE_ENTRY(IFolderCompare)
MY_QUERYINTERFACE_ENTRY(IFolderGetItemName)
MY_QUERYINTERFACE_ENTRY(IArchiveFolder)
MY_QUERYINTERFACE_ENTRY(IArchiveFolderInternal)
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
MY_QUERYINTERFACE_ENTRY(IFolderSetZoneIdMode)
#ifdef NEW_FOLDER_INTERFACE
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
#endif
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
HRESULT BindToFolder_Internal(unsigned proxyDirIndex, IFolderFolder **resultFolder);
HRESULT BindToAltStreams_Internal(unsigned proxyDirIndex, IFolderFolder **resultFolder);
int GetRealIndex(unsigned index) const;
void GetRealIndices(const UInt32 *indices, UInt32 numItems,
bool includeAltStreams, bool includeFolderSubItemsInFlatMode, CUIntVector &realIndices) const;
INTERFACE_IFolderSetZoneIdMode(;)
INTERFACE_FolderFolder(;)
INTERFACE_FolderAltStreams(;)
INTERFACE_FolderProperties(;)
INTERFACE_IArchiveGetRawProps(;)
INTERFACE_IFolderGetItemName(;)
STDMETHOD(GetFolderArcProps)(IFolderArcProps **object);
STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw);
int CompareItems3(UInt32 index1, UInt32 index2, PROPID propID);
int CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw);
// IArchiveFolder
INTERFACE_IArchiveFolder(;)
STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder);
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
#ifdef NEW_FOLDER_INTERFACE
INTERFACE_FolderOperations(;)
STDMETHOD(SetFlatMode)(Int32 flatMode);
#endif
CAgentFolder():
_proxyDirIndex(0),
_isAltStreamFolder(false),
@@ -173,32 +160,32 @@ public:
NExtract::NZoneIdMode::EEnum _zoneMode;
};
class CAgent:
class CAgent Z7_final:
public IInFolderArchive,
public IFolderArcProps,
#ifndef EXTRACT_ONLY
#ifndef Z7_EXTRACT_ONLY
public IOutFolderArchive,
public ISetProperties,
#endif
#endif
public CMyUnknownImp
{
Z7_COM_QI_BEGIN2(IInFolderArchive)
Z7_COM_QI_ENTRY(IFolderArcProps)
#ifndef Z7_EXTRACT_ONLY
Z7_COM_QI_ENTRY(IOutFolderArchive)
Z7_COM_QI_ENTRY(ISetProperties)
#endif
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_COM7_IMP(IInFolderArchive)
Z7_IFACE_COM7_IMP(IFolderArcProps)
#ifndef Z7_EXTRACT_ONLY
Z7_IFACE_COM7_IMP(ISetProperties)
public:
MY_QUERYINTERFACE_BEGIN2(IInFolderArchive)
MY_QUERYINTERFACE_ENTRY(IFolderArcProps)
#ifndef EXTRACT_ONLY
MY_QUERYINTERFACE_ENTRY(IOutFolderArchive)
MY_QUERYINTERFACE_ENTRY(ISetProperties)
#endif
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
INTERFACE_IInFolderArchive(;)
INTERFACE_IFolderArcProps(;)
#ifndef EXTRACT_ONLY
INTERFACE_IOutFolderArchive(;)
Z7_IFACE_COM7_IMP(IOutFolderArchive)
HRESULT CommonUpdate(ISequentialOutStream *outArchiveStream,
unsigned numUpdateItems, IArchiveUpdateCallback *updateCallback);
@@ -216,15 +203,11 @@ public:
HRESULT UpdateOneFile(ISequentialOutStream *outArchiveStream,
const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
IFolderArchiveUpdateCallback *updateCallback100);
#endif
// ISetProperties
STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
#endif
CAgent();
~CAgent();
private:
HRESULT ReadItems();
public:
CProxyArc *_proxy;
CProxyArc2 *_proxy2;
@@ -248,13 +231,16 @@ public:
bool _isHashHandler;
FString _hashBaseFolderPrefix;
#ifndef EXTRACT_ONLY
#ifndef Z7_EXTRACT_ONLY
CObjectVector<UString> m_PropNames;
CObjectVector<NWindows::NCOM::CPropVariant> m_PropValues;
#endif
#endif
CAgent();
~CAgent();
const CArc &GetArc() const { return _archiveLink.Arcs.Back(); }
IInArchive *GetArchive() const { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
IInArchive *GetArchive() const { if ( _archiveLink.Arcs.IsEmpty()) return NULL; return GetArc().Archive; }
bool CanUpdate() const;
bool Is_Attrib_ReadOnly() const
@@ -285,7 +271,7 @@ public:
UString GetErrorMessage() const
{
UString s;
for (int i = _archiveLink.Arcs.Size() - 1; i >= 0; i--)
for (int i = (int)_archiveLink.Arcs.Size() - 1; i >= 0; i--)
{
const CArc &arc = _archiveLink.Arcs[i];
@@ -326,23 +312,42 @@ public:
}
void KeepModeForNextOpen() { _archiveLink.KeepModeForNextOpen(); }
};
#ifdef NEW_FOLDER_INTERFACE
// #ifdef NEW_FOLDER_INTERFACE
class CArchiveFolderManager:
public IFolderManager,
public CMyUnknownImp
struct CCodecIcons
{
void LoadFormats();
int FindFormat(const UString &type);
public:
MY_UNKNOWN_IMP1(IFolderManager)
INTERFACE_IFolderManager(;)
struct CIconPair
{
UString Ext;
int IconIndex;
};
CObjectVector<CIconPair> IconPairs;
// void Clear() { IconPairs.Clear(); }
void LoadIcons(HMODULE m);
bool FindIconIndex(const UString &ext, int &iconIndex) const;
};
#endif
Z7_CLASS_IMP_COM_1(
CArchiveFolderManager
, IFolderManager
)
CObjectVector<CCodecIcons> CodecIconsVector;
CCodecIcons InternalIcons;
bool WasLoaded;
void LoadFormats();
// int FindFormat(const UString &type);
public:
CArchiveFolderManager():
WasLoaded(false)
{}
};
// #endif
#endif

View File

@@ -20,7 +20,7 @@
using namespace NWindows;
using namespace NCOM;
STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
Z7_COM7F_IMF(CAgent::SetFolder(IFolderFolder *folder))
{
_updatePathPrefix.Empty();
_updatePathPrefix_is_AltFolder = false;
@@ -30,11 +30,12 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
return S_OK;
{
CMyComPtr<IArchiveFolderInternal> afi;
RINOK(folder->QueryInterface(IID_IArchiveFolderInternal, (void **)&afi));
Z7_DECL_CMyComPtr_QI_FROM(
IArchiveFolderInternal,
afi, folder)
if (afi)
{
RINOK(afi->GetAgentFolder(&_agentFolder));
RINOK(afi->GetAgentFolder(&_agentFolder))
}
if (!_agentFolder)
return E_FAIL;
@@ -47,8 +48,8 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
return S_OK;
}
STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
const wchar_t * const *names, UInt32 numNames)
Z7_COM7F_IMF(CAgent::SetFiles(const wchar_t *folderPrefix,
const wchar_t * const *names, UInt32 numNames))
{
_folderPrefix = us2fs(folderPrefix);
_names.ClearAndReserve(numNames);
@@ -69,8 +70,8 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
unsigned arcIndex = item.SubFiles[i];
const CProxyFile &fileItem = agent->_proxy->Files[arcIndex];
CArcItem ai;
RINOK(agent->GetArc().GetItem_MTime(arcIndex, ai.MTime));
RINOK(agent->GetArc().GetItem_Size(arcIndex, ai.Size, ai.Size_Defined));
RINOK(agent->GetArc().GetItem_MTime(arcIndex, ai.MTime))
RINOK(agent->GetArc().GetItem_Size(arcIndex, ai.Size, ai.Size_Defined))
ai.IsDir = false;
ai.Name = prefix + fileItem.Name;
ai.Censored = true; // test it
@@ -85,15 +86,15 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
if (dirItem.IsLeaf())
{
CArcItem ai;
RINOK(agent->GetArc().GetItem_MTime(dirItem.ArcIndex, ai.MTime));
RINOK(agent->GetArc().GetItem_MTime((unsigned)dirItem.ArcIndex, ai.MTime))
ai.IsDir = true;
ai.Size_Defined = false;
ai.Name = fullName;
ai.Censored = true; // test it
ai.IndexInServer = dirItem.ArcIndex;
ai.IndexInServer = (unsigned)dirItem.ArcIndex;
arcItems.Add(ai);
}
RINOK(EnumerateArchiveItems(agent, dirItem, fullName + WCHAR_PATH_SEPARATOR, arcItems));
RINOK(EnumerateArchiveItems(agent, dirItem, fullName + WCHAR_PATH_SEPARATOR, arcItems))
}
return S_OK;
@@ -113,38 +114,38 @@ static HRESULT EnumerateArchiveItems2(const CAgent *agent,
ai.IndexInServer = arcIndex;
ai.Name = prefix + file.Name;
ai.Censored = true; // test it
RINOK(agent->GetArc().GetItem_MTime(arcIndex, ai.MTime));
RINOK(agent->GetArc().GetItem_MTime(arcIndex, ai.MTime))
ai.IsDir = file.IsDir();
ai.Size_Defined = false;
ai.IsAltStream = file.IsAltStream;
if (!ai.IsDir)
{
RINOK(agent->GetArc().GetItem_Size(arcIndex, ai.Size, ai.Size_Defined));
RINOK(agent->GetArc().GetItem_Size(arcIndex, ai.Size, ai.Size_Defined))
ai.IsDir = false;
}
arcItems.Add(ai);
if (file.AltDirIndex != -1)
{
RINOK(EnumerateArchiveItems2(agent, file.AltDirIndex, ai.Name + L':', arcItems));
RINOK(EnumerateArchiveItems2(agent, (unsigned)file.AltDirIndex, ai.Name + L':', arcItems))
}
if (ai.IsDir)
{
RINOK(EnumerateArchiveItems2(agent, file.DirIndex, ai.Name + WCHAR_PATH_SEPARATOR, arcItems));
RINOK(EnumerateArchiveItems2(agent, (unsigned)file.DirIndex, ai.Name + WCHAR_PATH_SEPARATOR, arcItems))
}
}
return S_OK;
}
struct CAgUpCallbackImp: public IUpdateProduceCallback
struct CAgUpCallbackImp Z7_final: public IUpdateProduceCallback
{
const CObjectVector<CArcItem> *_arcItems;
IFolderArchiveUpdateCallback *_callback;
CAgUpCallbackImp(const CObjectVector<CArcItem> *a,
IFolderArchiveUpdateCallback *callback): _arcItems(a), _callback(callback) {}
HRESULT ShowDeleteFile(unsigned arcIndex);
HRESULT ShowDeleteFile(unsigned arcIndex) Z7_override;
};
HRESULT CAgUpCallbackImp::ShowDeleteFile(unsigned arcIndex)
@@ -164,7 +165,7 @@ static void SetInArchiveInterfaces(CAgent *agent, CArchiveUpdateCallback *upd)
upd->ArcFileName = ExtractFileNameFromPath(arc.Path);
}
struct CDirItemsCallback_AgentOut: public IDirItemsCallback
struct CDirItemsCallback_AgentOut Z7_final: public IDirItemsCallback
{
CMyComPtr<IFolderScanProgress> FolderScanProgress;
IFolderArchiveUpdateCallback *FolderArchiveUpdateCallback;
@@ -172,30 +173,28 @@ struct CDirItemsCallback_AgentOut: public IDirItemsCallback
CDirItemsCallback_AgentOut(): FolderArchiveUpdateCallback(NULL), ErrorCode(S_OK) {}
HRESULT ScanError(const FString &name, DWORD systemError)
HRESULT ScanError(const FString &name, DWORD systemError) Z7_override
{
HRESULT hres = HRESULT_FROM_WIN32(systemError);
const HRESULT hres = HRESULT_FROM_WIN32(systemError);
if (FolderArchiveUpdateCallback)
return FolderScanProgress->ScanError(fs2us(name), hres);
ErrorCode = hres;
return ErrorCode;
}
HRESULT ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir)
HRESULT ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir) Z7_override
{
if (FolderScanProgress)
return FolderScanProgress->ScanProgress(st.NumDirs, st.NumFiles + st.NumAltStreams,
st.GetTotalBytes(), fs2us(path), BoolToInt(isDir));
if (FolderArchiveUpdateCallback)
return FolderArchiveUpdateCallback->SetNumFiles(st.NumFiles);
return S_OK;
}
};
STDMETHODIMP CAgent::DoOperation(
Z7_COM7F_IMF(CAgent::DoOperation(
FStringVector *requestedPaths,
FStringVector *processedPaths,
CCodecs *codecs,
@@ -203,7 +202,7 @@ STDMETHODIMP CAgent::DoOperation(
ISequentialOutStream *outArchiveStream,
const Byte *stateActions,
const wchar_t *sfxModule,
IFolderArchiveUpdateCallback *updateCallback100)
IFolderArchiveUpdateCallback *updateCallback100))
{
if (!CanUpdate())
return E_NOTIMPL;
@@ -226,9 +225,10 @@ STDMETHODIMP CAgent::DoOperation(
{
FString folderPrefix = _folderPrefix;
NFile::NName::NormalizeDirPathPrefix(folderPrefix);
if (!NFile::NName::IsAltStreamPrefixWithColon(fs2us(folderPrefix)))
NFile::NName::NormalizeDirPathPrefix(folderPrefix);
RINOK(dirItems.EnumerateItems2(folderPrefix, _updatePathPrefix, _names, requestedPaths));
RINOK(dirItems.EnumerateItems2(folderPrefix, _updatePathPrefix, _names, requestedPaths))
if (_updatePathPrefix_is_AltFolder)
{
@@ -246,21 +246,21 @@ STDMETHODIMP CAgent::DoOperation(
if (GetArchive())
{
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive))
}
else
{
if (formatIndex < 0)
return E_FAIL;
RINOK(codecs->CreateOutArchive(formatIndex, outArchive));
RINOK(codecs->CreateOutArchive((unsigned)formatIndex, outArchive))
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
{
CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
if (setCompressCodecsInfo)
{
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs))
}
}
#endif
@@ -268,7 +268,7 @@ STDMETHODIMP CAgent::DoOperation(
NFileTimeType::EEnum fileTimeType = NFileTimeType::kNotDefined;
UInt32 value;
RINOK(outArchive->GetFileTimeType(&value));
RINOK(outArchive->GetFileTimeType(&value))
// we support any future fileType here.
// 22.00:
fileTimeType = (NFileTimeType::EEnum)value;
@@ -291,15 +291,15 @@ STDMETHODIMP CAgent::DoOperation(
CObjectVector<CArcItem> arcItems;
if (GetArchive())
{
RINOK(ReadItems());
RINOK(ReadItems())
if (_proxy2)
{
RINOK(EnumerateArchiveItems2(this, k_Proxy2_RootDirIndex, L"", arcItems));
RINOK(EnumerateArchiveItems2(this, k_Proxy2_AltRootDirIndex, L":", arcItems));
RINOK(EnumerateArchiveItems2(this, k_Proxy2_RootDirIndex, L"", arcItems))
RINOK(EnumerateArchiveItems2(this, k_Proxy2_AltRootDirIndex, L":", arcItems))
}
else
{
RINOK(EnumerateArchiveItems(this, _proxy->Dirs[0], L"", arcItems));
RINOK(EnumerateArchiveItems(this, _proxy->Dirs[0], L"", arcItems))
}
}
@@ -321,7 +321,7 @@ STDMETHODIMP CAgent::DoOperation(
if (updateCallback100)
{
RINOK(updateCallback100->SetNumFiles(numFiles));
RINOK(updateCallback100->SetNumFiles(numFiles))
}
CUpdateCallbackAgent updateCallbackAgent;
@@ -347,12 +347,14 @@ STDMETHODIMP CAgent::DoOperation(
updateCallbackSpec->ProcessedItemsStatuses = processedItems;
}
CMyComPtr<ISetProperties> setProperties;
if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
Z7_DECL_CMyComPtr_QI_FROM(
ISetProperties,
setProperties, outArchive)
if (setProperties)
{
if (m_PropNames.Size() == 0)
{
RINOK(setProperties->SetProperties(0, 0, 0));
RINOK(setProperties->SetProperties(NULL, NULL, 0))
}
else
{
@@ -365,7 +367,7 @@ STDMETHODIMP CAgent::DoOperation(
{
FOR_VECTOR (i, m_PropValues)
propValues[i] = m_PropValues[i];
RINOK(setProperties->SetProperties(&names.Front(), propValues, names.Size()));
RINOK(setProperties->SetProperties(&names.Front(), propValues, names.Size()))
}
catch(...)
{
@@ -385,7 +387,7 @@ STDMETHODIMP CAgent::DoOperation(
if (!sfxStreamSpec->Open(us2fs(sfxModule)))
return E_FAIL;
// throw "Can't open sfx module";
RINOK(NCompress::CopyStream(sfxStream, outArchiveStream, NULL));
RINOK(NCompress::CopyStream(sfxStream, outArchiveStream, NULL))
}
HRESULT res = outArchive->UpdateItems(outArchiveStream, updatePairs2.Size(), updateCallback);
@@ -413,11 +415,11 @@ STDMETHODIMP CAgent::DoOperation(
return res;
}
STDMETHODIMP CAgent::DoOperation2(
Z7_COM7F_IMF(CAgent::DoOperation2(
FStringVector *requestedPaths,
FStringVector *processedPaths,
ISequentialOutStream *outArchiveStream,
const Byte *stateActions, const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback100)
const Byte *stateActions, const wchar_t *sfxModule, IFolderArchiveUpdateCallback *updateCallback100))
{
return DoOperation(requestedPaths, processedPaths, g_CodecsObj, -1, outArchiveStream, stateActions, sfxModule, updateCallback100);
}
@@ -428,13 +430,13 @@ HRESULT CAgent::CommonUpdate(ISequentialOutStream *outArchiveStream,
if (!CanUpdate())
return E_NOTIMPL;
CMyComPtr<IOutArchive> outArchive;
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive));
RINOK(GetArchive()->QueryInterface(IID_IOutArchive, (void **)&outArchive))
return outArchive->UpdateItems(outArchiveStream, numUpdateItems, updateCallback);
}
STDMETHODIMP CAgent::DeleteItems(ISequentialOutStream *outArchiveStream,
Z7_COM7F_IMF(CAgent::DeleteItems(ISequentialOutStream *outArchiveStream,
const UInt32 *indices, UInt32 numItems,
IFolderArchiveUpdateCallback *updateCallback100)
IFolderArchiveUpdateCallback *updateCallback100))
{
if (!CanUpdate())
return E_NOTIMPL;
@@ -451,7 +453,7 @@ STDMETHODIMP CAgent::DeleteItems(ISequentialOutStream *outArchiveStream,
realIndices);
unsigned curIndex = 0;
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive))
UString deletePath;
@@ -460,8 +462,8 @@ STDMETHODIMP CAgent::DeleteItems(ISequentialOutStream *outArchiveStream,
if (curIndex < realIndices.Size())
if (realIndices[curIndex] == i)
{
RINOK(GetArc().GetItem_Path2(i, deletePath));
RINOK(updateCallback100->DeleteOperation(deletePath));
RINOK(GetArc().GetItem_Path2(i, deletePath))
RINOK(updateCallback100->DeleteOperation(deletePath))
curIndex++;
continue;
@@ -491,7 +493,7 @@ HRESULT CAgent::CreateFolder(ISequentialOutStream *outArchiveStream,
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive))
for (UInt32 i = 0; i < numItemsInArchive; i++)
{
CUpdatePair2 up2;
@@ -569,7 +571,7 @@ HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
unsigned curIndex = 0;
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive))
for (UInt32 i = 0; i < numItemsInArchive; i++)
{
@@ -579,15 +581,15 @@ HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
if (realIndices[curIndex] == i)
{
up2.NewProps = true;
RINOK(GetArc().IsItem_Anti(i, up2.IsAnti)); // it must work without that line too.
RINOK(GetArc().IsItem_Anti(i, up2.IsAnti)) // it must work without that line too.
UString oldFullPath;
RINOK(GetArc().GetItem_Path2(i, oldFullPath));
RINOK(GetArc().GetItem_Path2(i, oldFullPath))
if (!IsPath1PrefixedByPath2(oldFullPath, oldItemPath))
return E_INVALIDARG;
up2.NewNameIndex = newNames.Add(newItemPath + oldFullPath.Ptr(oldItemPath.Len()));
up2.NewNameIndex = (int)newNames.Add(newItemPath + oldFullPath.Ptr(oldItemPath.Len()));
up2.IsMainRenameItem = (mainRealIndex == (int)i);
curIndex++;
}
@@ -627,7 +629,7 @@ HRESULT CAgent::CommentItem(ISequentialOutStream *outArchiveStream,
return E_NOTIMPL;
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive))
UString newName = newItemName;
@@ -686,7 +688,7 @@ HRESULT CAgent::UpdateOneFile(ISequentialOutStream *outArchiveStream,
}
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive))
for (UInt32 i = 0; i < numItemsInArchive; i++)
{
CUpdatePair2 up2;
@@ -710,7 +712,7 @@ HRESULT CAgent::UpdateOneFile(ISequentialOutStream *outArchiveStream,
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
}
STDMETHODIMP CAgent::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
Z7_COM7F_IMF(CAgent::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps))
{
m_PropNames.Clear();
m_PropValues.Clear();

View File

@@ -39,7 +39,7 @@ int CProxyArc::FindSubDir(unsigned dirIndex, const wchar_t *name, unsigned &inse
const unsigned dirIndex2 = subDirs[mid];
const int comp = CompareFileNames(name, Dirs[dirIndex2].Name);
if (comp == 0)
return dirIndex2;
return (int)dirIndex2;
if (comp < 0)
right = mid;
else
@@ -77,18 +77,18 @@ unsigned CProxyArc::AddDir(unsigned dirIndex, int arcIndex, const UString &name)
if (item.ArcIndex == -1)
item.ArcIndex = arcIndex;
}
return subDirIndex;
return (unsigned)subDirIndex;
}
subDirIndex = Dirs.Size();
Dirs[dirIndex].SubDirs.Insert(insertPos, subDirIndex);
subDirIndex = (int)Dirs.Size();
Dirs[dirIndex].SubDirs.Insert(insertPos, (unsigned)subDirIndex);
CProxyDir &item = Dirs.AddNew();
item.NameLen = name.Len();
item.Name = AllocStringAndCopy(name);
item.ArcIndex = arcIndex;
item.ParentDir = dirIndex;
return subDirIndex;
item.ParentDir = (int)dirIndex;
return (unsigned)subDirIndex;
}
void CProxyDir::Clear()
@@ -97,14 +97,15 @@ void CProxyDir::Clear()
SubFiles.Clear();
}
void CProxyArc::GetDirPathParts(int dirIndex, UStringVector &pathParts) const
void CProxyArc::GetDirPathParts(unsigned dirIndex, UStringVector &pathParts) const
{
pathParts.Clear();
while (dirIndex != -1)
// while (dirIndex != -1)
for (;;)
{
const CProxyDir &dir = Dirs[dirIndex];
dirIndex = dir.ParentDir;
if (dirIndex == -1)
dirIndex = (unsigned)dir.ParentDir;
if (dir.ParentDir == -1)
break;
pathParts.Insert(0, dir.Name);
// 22.00: we normalize name
@@ -112,14 +113,15 @@ void CProxyArc::GetDirPathParts(int dirIndex, UStringVector &pathParts) const
}
}
UString CProxyArc::GetDirPath_as_Prefix(int dirIndex) const
UString CProxyArc::GetDirPath_as_Prefix(unsigned dirIndex) const
{
UString s;
while (dirIndex != -1)
// while (dirIndex != -1)
for (;;)
{
const CProxyDir &dir = Dirs[dirIndex];
dirIndex = dir.ParentDir;
if (dirIndex == -1)
dirIndex = (unsigned)dir.ParentDir;
if (dir.ParentDir == -1)
break;
s.InsertAtFront(WCHAR_PATH_SEPARATOR);
s.Insert(0, dir.Name);
@@ -133,7 +135,7 @@ void CProxyArc::AddRealIndices(unsigned dirIndex, CUIntVector &realIndices) cons
{
const CProxyDir &dir = Dirs[dirIndex];
if (dir.IsLeaf())
realIndices.Add(dir.ArcIndex);
realIndices.Add((unsigned)dir.ArcIndex);
unsigned i;
for (i = 0; i < dir.SubDirs.Size(); i++)
AddRealIndices(dir.SubDirs[i], realIndices);
@@ -152,7 +154,7 @@ int CProxyArc::GetRealIndex(unsigned dirIndex, unsigned index) const
return f.ArcIndex;
return -1;
}
return dir.SubFiles[index - numDirItems];
return (int)dir.SubFiles[index - numDirItems];
}
void CProxyArc::GetRealIndices(unsigned dirIndex, const UInt32 *indices, UInt32 numItems, CUIntVector &realIndices) const
@@ -242,10 +244,10 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
IInArchive *archive = arc.Archive;
UInt32 numItems;
RINOK(archive->GetNumberOfItems(&numItems));
RINOK(archive->GetNumberOfItems(&numItems))
if (progress)
RINOK(progress->SetTotal(numItems));
RINOK(progress->SetTotal(numItems))
Files.Alloc(numItems);
@@ -258,7 +260,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
if (progress && (i & 0xFFFF) == 0)
{
const UInt64 currentItemIndex = i;
RINOK(progress->SetCompleted(&currentItemIndex));
RINOK(progress->SetCompleted(&currentItemIndex))
}
const wchar_t *s = NULL;
@@ -293,7 +295,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
#endif
{
prop.Clear();
RINOK(arc.Archive->GetProperty(i, kpidPath, &prop));
RINOK(arc.Archive->GetProperty(i, kpidPath, &prop))
if (prop.vt == VT_BSTR)
{
s = prop.bstrVal;
@@ -303,7 +305,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
return E_FAIL;
if (len == 0)
{
RINOK(arc.GetItem_DefaultPath(i, path));
RINOK(arc.GetItem_DefaultPath(i, path))
len = path.Len();
s = path;
}
@@ -370,7 +372,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
*/
bool isDir;
RINOK(Archive_IsItem_Dir(archive, i, isDir));
RINOK(Archive_IsItem_Dir(archive, i, isDir))
CProxyFile &f = Files[i];
@@ -407,31 +409,32 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
// ---------- for Tree-mode archive ----------
void CProxyArc2::GetDirPathParts(int dirIndex, UStringVector &pathParts, bool &isAltStreamDir) const
void CProxyArc2::GetDirPathParts(unsigned dirIndex, UStringVector &pathParts, bool &isAltStreamDir) const
{
pathParts.Clear();
isAltStreamDir = false;
if (dirIndex == (int)k_Proxy2_RootDirIndex)
if (dirIndex == k_Proxy2_RootDirIndex)
return;
if (dirIndex == (int)k_Proxy2_AltRootDirIndex)
if (dirIndex == k_Proxy2_AltRootDirIndex)
{
isAltStreamDir = true;
return;
}
while (dirIndex >= (int)k_Proxy2_NumRootDirs)
while (dirIndex >= k_Proxy2_NumRootDirs)
{
const CProxyDir2 &dir = Dirs[dirIndex];
const CProxyFile2 &file = Files[(unsigned)dir.ArcIndex];
if (pathParts.IsEmpty() && dirIndex == file.AltDirIndex)
if (pathParts.IsEmpty() && (int)dirIndex == file.AltDirIndex)
isAltStreamDir = true;
pathParts.Insert(0, file.Name);
int par = file.Parent;
const int par = file.Parent;
if (par == -1)
break;
dirIndex = Files[(unsigned)par].DirIndex;
dirIndex = (unsigned)Files[(unsigned)par].DirIndex;
// if ((int)dirIndex == -1) break;
}
}
@@ -465,9 +468,9 @@ void CProxyArc2::AddRealIndices_of_ArcItem(unsigned arcIndex, bool includeAltStr
realIndices.Add(arcIndex);
const CProxyFile2 &file = Files[arcIndex];
if (file.DirIndex != -1)
AddRealIndices_of_Dir(file.DirIndex, includeAltStreams, realIndices);
AddRealIndices_of_Dir((unsigned)file.DirIndex, includeAltStreams, realIndices);
if (includeAltStreams && file.AltDirIndex != -1)
AddRealIndices_of_Dir(file.AltDirIndex, includeAltStreams, realIndices);
AddRealIndices_of_Dir((unsigned)file.AltDirIndex, includeAltStreams, realIndices);
}
void CProxyArc2::AddRealIndices_of_Dir(unsigned dirIndex, bool includeAltStreams, CUIntVector &realIndices) const
@@ -538,7 +541,7 @@ void CProxyArc2::CalculateSizes(unsigned dirIndex, IInArchive *archive)
dir.NumSubDirs++;
CProxyDir2 &f = Dirs[subFile.DirIndex];
f.PathPrefix = dir.PathPrefix + s + WCHAR_PATH_SEPARATOR;
CalculateSizes(subFile.DirIndex, archive);
CalculateSizes((unsigned)subFile.DirIndex, archive);
dir.Size += f.Size;
dir.PackSize += f.PackSize;
dir.NumSubFiles += f.NumSubFiles;
@@ -557,7 +560,7 @@ void CProxyArc2::CalculateSizes(unsigned dirIndex, IInArchive *archive)
// dir.NumSubDirs++;
CProxyDir2 &f = Dirs[subFile.AltDirIndex];
f.PathPrefix = dir.PathPrefix + subFile.Name + L':';
CalculateSizes(subFile.AltDirIndex, archive);
CalculateSizes((unsigned)subFile.AltDirIndex, archive);
}
}
}
@@ -589,9 +592,9 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
IInArchive *archive = arc.Archive;
UInt32 numItems;
RINOK(archive->GetNumberOfItems(&numItems));
RINOK(archive->GetNumberOfItems(&numItems))
if (progress)
RINOK(progress->SetTotal(numItems));
RINOK(progress->SetTotal(numItems))
UString fileName;
@@ -617,7 +620,7 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
if (progress && (i & 0xFFFFF) == 0)
{
UInt64 currentItemIndex = i;
RINOK(progress->SetCompleted(&currentItemIndex));
RINOK(progress->SetCompleted(&currentItemIndex))
}
CProxyFile2 &file = Files[i];
@@ -625,7 +628,7 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
const void *p;
UInt32 size;
UInt32 propType;
RINOK(arc.GetRawProps->GetRawProp(i, kpidName, &p, &size, &propType));
RINOK(arc.GetRawProps->GetRawProp(i, kpidName, &p, &size, &propType))
#ifdef MY_CPU_LE
if (p && propType == PROP_DATA_TYPE_wchar_t_PTR_Z_LE)
@@ -648,7 +651,7 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
else
{
NCOM::CPropVariant prop;
RINOK(arc.Archive->GetProperty(i, kpidName, &prop));
RINOK(arc.Archive->GetProperty(i, kpidName, &prop))
const wchar_t *s;
if (prop.vt == VT_BSTR)
s = prop.bstrVal;
@@ -663,13 +666,13 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
UInt32 parent = (UInt32)(Int32)-1;
UInt32 parentType = 0;
RINOK(arc.GetRawProps->GetParent(i, &parent, &parentType));
RINOK(arc.GetRawProps->GetParent(i, &parent, &parentType))
file.Parent = (Int32)parent;
if (arc.Ask_Deleted)
{
bool isDeleted = false;
RINOK(Archive_IsItem_Deleted(archive, i, isDeleted));
RINOK(Archive_IsItem_Deleted(archive, i, isDeleted))
if (isDeleted)
{
// continue;
@@ -678,16 +681,16 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
}
bool isDir;
RINOK(Archive_IsItem_Dir(archive, i, isDir));
RINOK(Archive_IsItem_Dir(archive, i, isDir))
if (isDir)
{
file.DirIndex = Dirs.Size();
file.DirIndex = (int)Dirs.Size();
CProxyDir2 &dir = Dirs.AddNew();
dir.ArcIndex = i;
dir.ArcIndex = (int)i;
}
if (arc.Ask_AltStream)
RINOK(Archive_IsItem_AltStream(archive, i, file.IsAltStream));
RINOK(Archive_IsItem_AltStream(archive, i, file.IsAltStream))
}
for (i = 0; i < numItems; i++)
@@ -704,7 +707,7 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
int &folderIndex2 = Files[(unsigned)file.Parent].AltDirIndex;
if (folderIndex2 == -1)
{
folderIndex2 = Dirs.Size();
folderIndex2 = (int)Dirs.Size();
CProxyDir2 &dir = Dirs.AddNew();
dir.ArcIndex = file.Parent;
}
@@ -743,7 +746,7 @@ int CProxyArc2::FindItem(unsigned dirIndex, const wchar_t *name, bool foldersOnl
if (foldersOnly && file.DirIndex == -1)
continue;
if (CompareFileNames(file.Name, name) == 0)
return i;
return (int)i;
}
return -1;
}

View File

@@ -1,7 +1,7 @@
// AgentProxy.h
#ifndef __AGENT_PROXY_H
#define __AGENT_PROXY_H
#ifndef ZIP7_INC_AGENT_PROXY_H
#define ZIP7_INC_AGENT_PROXY_H
#include "../Common/OpenArchive.h"
@@ -34,7 +34,7 @@ struct CProxyDir
UInt32 NumSubFiles;
bool CrcIsDefined;
CProxyDir(): Name(NULL), NameLen(0), ParentDir(-1) {};
CProxyDir(): Name(NULL), NameLen(0), ParentDir(-1) {}
~CProxyDir() { delete [](wchar_t *)(void *)Name; }
void Clear();
@@ -54,9 +54,9 @@ public:
// returns index in Dirs[], or -1,
int FindSubDir(unsigned dirIndex, const wchar_t *name) const;
void GetDirPathParts(int dirIndex, UStringVector &pathParts) const;
void GetDirPathParts(unsigned dirIndex, UStringVector &pathParts) const;
// returns full path of Dirs[dirIndex], including back slash
UString GetDirPath_as_Prefix(int dirIndex) const;
UString GetDirPath_as_Prefix(unsigned dirIndex) const;
// AddRealIndices DOES ADD also item represented by dirIndex (if it's Leaf)
void AddRealIndices(unsigned dirIndex, CUIntVector &realIndices) const;
@@ -73,7 +73,7 @@ struct CProxyFile2
{
int DirIndex; // >= 0 for dir. (index in ProxyArchive2->Dirs)
int AltDirIndex; // >= 0 if there are alt streams. (index in ProxyArchive2->Dirs)
int Parent; // >= 0 if there is parent. (index in archive and in ProxyArchive2->Files)
int Parent; // >= 0 if there is parent. (index in archive and in ProxyArchive2->Files)
const wchar_t *Name;
unsigned NameLen;
bool NeedDeleteName;
@@ -109,7 +109,7 @@ struct CProxyDir2
UInt32 NumSubDirs;
UInt32 NumSubFiles;
CProxyDir2(): ArcIndex(-1) {};
CProxyDir2(): ArcIndex(-1) {}
void AddFileSubItem(UInt32 index, const UString &name);
void Clear();
};
@@ -130,7 +130,7 @@ public:
bool IsThere_SubDir(unsigned dirIndex, const UString &name) const;
void GetDirPathParts(int dirIndex, UStringVector &pathParts, bool &isAltStreamDir) const;
void GetDirPathParts(unsigned dirIndex, UStringVector &pathParts, bool &isAltStreamDir) const;
UString GetDirPath_as_Prefix(unsigned dirIndex, bool &isAltStreamDir) const;
bool IsAltDir(unsigned dirIndex) const;

View File

@@ -9,22 +9,23 @@
#include "Agent.h"
/*
STDMETHODIMP CAgentFolder::SetReplaceAltStreamCharsMode(Int32 replaceAltStreamCharsMode)
Z7_COM7F_IMF(CAgentFolder::SetReplaceAltStreamCharsMode(Int32 replaceAltStreamCharsMode))
{
_replaceAltStreamCharsMode = replaceAltStreamCharsMode;
return S_OK;
}
*/
STDMETHODIMP CAgentFolder::SetZoneIdMode(NExtract::NZoneIdMode::EEnum zoneMode)
Z7_COM7F_IMF(CAgentFolder::SetZoneIdMode(NExtract::NZoneIdMode::EEnum zoneMode))
{
_zoneMode = zoneMode;
return S_OK;
}
STDMETHODIMP CAgentFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
Z7_COM7F_IMF(CAgentFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
Int32 includeAltStreams, Int32 replaceAltStreamCharsMode,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
const wchar_t *path, IFolderOperationsExtractCallback *callback))
{
if (moveMode)
return E_NOTIMPL;
@@ -32,7 +33,7 @@ STDMETHODIMP CAgentFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32
CMyComPtr<IFolderArchiveExtractCallback> extractCallback2;
{
CMyComPtr<IFolderOperationsExtractCallback> callbackWrap = callback;
RINOK(callbackWrap.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2));
RINOK(callbackWrap.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2))
}
NExtract::NPathMode::EEnum pathMode;
if (!_flatMode)

View File

@@ -2,26 +2,96 @@
#include "StdAfx.h"
// #ifdef NEW_FOLDER_INTERFACE
#include "../../../Common/StringToInt.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/ResourceString.h"
#include "Agent.h"
void CArchiveFolderManager::LoadFormats()
extern HINSTANCE g_hInstance;
static const UINT kIconTypesResId = 100;
void CCodecIcons::LoadIcons(HMODULE m)
{
LoadGlobalCodecs();
IconPairs.Clear();
UString iconTypes;
NWindows::MyLoadString(m, kIconTypesResId, iconTypes);
UStringVector pairs;
SplitString(iconTypes, pairs);
FOR_VECTOR (i, pairs)
{
const UString &s = pairs[i];
int pos = s.Find(L':');
CIconPair iconPair;
iconPair.IconIndex = -1;
if (pos < 0)
pos = (int)s.Len();
else
{
const UString num = s.Ptr((unsigned)pos + 1);
if (!num.IsEmpty())
{
const wchar_t *end;
iconPair.IconIndex = (int)ConvertStringToUInt32(num, &end);
if (*end != 0)
continue;
}
}
iconPair.Ext = s.Left((unsigned)pos);
IconPairs.Add(iconPair);
}
}
bool CCodecIcons::FindIconIndex(const UString &ext, int &iconIndex) const
{
iconIndex = -1;
FOR_VECTOR (i, IconPairs)
{
const CIconPair &pair = IconPairs[i];
if (ext.IsEqualTo_NoCase(pair.Ext))
{
iconIndex = pair.IconIndex;
return true;
}
}
return false;
}
void CArchiveFolderManager::LoadFormats()
{
if (WasLoaded)
return;
LoadGlobalCodecs();
#ifdef Z7_EXTERNAL_CODECS
CodecIconsVector.Clear();
FOR_VECTOR (i, g_CodecsObj->Libs)
{
CCodecIcons &ci = CodecIconsVector.AddNew();
ci.LoadIcons(g_CodecsObj->Libs[i].Lib.Get_HMODULE());
}
#endif
InternalIcons.LoadIcons(g_hInstance);
WasLoaded = true;
}
/*
int CArchiveFolderManager::FindFormat(const UString &type)
{
FOR_VECTOR (i, g_CodecsObj->Formats)
if (type.IsEqualTo_NoCase(g_CodecsObj->Formats[i].Name))
return i;
return (int)i;
return -1;
}
*/
STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream,
Z7_COM7F_IMF(CArchiveFolderManager::OpenFolderFile(IInStream *inStream,
const wchar_t *filePath, const wchar_t *arcFormat,
IFolderFolder **resultFolder, IProgress *progress)
IFolderFolder **resultFolder, IProgress *progress))
{
CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
if (progress)
@@ -32,7 +102,7 @@ STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream,
CAgent *agent = new CAgent();
CMyComPtr<IInFolderArchive> archive = agent;
HRESULT res = agent->Open(inStream, filePath, arcFormat, NULL, openArchiveCallback);
const HRESULT res = archive->Open(inStream, filePath, arcFormat, NULL, openArchiveCallback);
if (res != S_OK)
{
@@ -44,7 +114,7 @@ STDMETHODIMP CArchiveFolderManager::OpenFolderFile(IInStream *inStream,
return res;
}
RINOK(agent->BindToRootFolder(resultFolder));
RINOK(archive->BindToRootFolder(resultFolder))
return res;
}
@@ -58,7 +128,7 @@ HRESULT CAgent::FolderReOpen(
/*
STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *extensions)
Z7_COM7F_IMF(CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *extensions))
{
*extensions = 0;
int formatIndex = FindFormat(type);
@@ -78,47 +148,52 @@ static void AddIconExt(const CCodecIcons &lib, UString &dest)
}
}
STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions)
Z7_COM7F_IMF(CArchiveFolderManager::GetExtensions(BSTR *extensions))
{
*extensions = NULL;
LoadFormats();
*extensions = 0;
UString res;
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
/*
FOR_VECTOR (i, g_CodecsObj->Libs)
AddIconExt(g_CodecsObj->Libs[i], res);
AddIconExt(g_CodecsObj->Libs[i].CodecIcons, res);
*/
FOR_VECTOR (i, CodecIconsVector)
AddIconExt(CodecIconsVector[i], res);
#endif
AddIconExt(g_CodecsObj->InternalIcons, res);
AddIconExt(
// g_CodecsObj->
InternalIcons, res);
return StringToBstr(res, extensions);
}
STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex)
{
*iconPath = 0;
*iconIndex = 0;
Z7_COM7F_IMF(CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex))
{
*iconPath = NULL;
*iconIndex = 0;
LoadFormats();
#ifdef EXTERNAL_CODECS
FOR_VECTOR (i, g_CodecsObj->Libs)
#ifdef Z7_EXTERNAL_CODECS
// FOR_VECTOR (i, g_CodecsObj->Libs)
FOR_VECTOR (i, CodecIconsVector)
{
const CCodecLib &lib = g_CodecsObj->Libs[i];
int ii;
if (lib.FindIconIndex(ext, ii))
if (CodecIconsVector[i].FindIconIndex(ext, ii))
{
const CCodecLib &lib = g_CodecsObj->Libs[i];
*iconIndex = ii;
return StringToBstr(fs2us(lib.Path), iconPath);
}
}
#endif
int ii;
if (g_CodecsObj->InternalIcons.FindIconIndex(ext, ii))
if (InternalIcons.FindIconIndex(ext, ii))
{
FString path;
if (NWindows::NDLL::MyGetModuleFileName(path))
@@ -131,7 +206,7 @@ STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPa
}
/*
STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
Z7_COM7F_IMF(CArchiveFolderManager::GetTypes(BSTR *types))
{
LoadFormats();
UString typesStrings;
@@ -146,9 +221,11 @@ STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
}
return StringToBstr(typesStrings, types);
}
STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
const wchar_t * filePath, IProgress progress)
Z7_COM7F_IMF(CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
const wchar_t * filePath, IProgress progress))
{
return E_NOTIMPL;
}
*/
// #endif

View File

@@ -83,7 +83,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
try
{
RINOK(_agentSpec->SetFolder(this));
RINOK(_agentSpec->SetFolder(this))
// ---------- Save FolderItem ----------
@@ -95,7 +95,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
FStringVector processedPaths;
CWorkDirTempFile tempFile;
RINOK(tempFile.CreateTempFile(us2fs(_agentSpec->_archiveFilePath)));
RINOK(tempFile.CreateTempFile(us2fs(_agentSpec->_archiveFilePath)))
{
CMyComPtr<IOutStream> tailStream;
const CArc &arc = *_agentSpec->_archiveLink.GetArc();
@@ -106,8 +106,8 @@ HRESULT CAgentFolder::CommonUpdateOperation(
{
if (arc.Offset < 0)
return E_NOTIMPL;
RINOK(arc.InStream->Seek(0, STREAM_SEEK_SET, NULL));
RINOK(NCompress::CopyStream_ExactSize(arc.InStream, tempFile.OutStream, arc.ArcStreamOffset, NULL));
RINOK(arc.InStream->Seek(0, STREAM_SEEK_SET, NULL))
RINOK(NCompress::CopyStream_ExactSize(arc.InStream, tempFile.OutStream, arc.ArcStreamOffset, NULL))
CTailOutStream *tailStreamSpec = new CTailOutStream;
tailStream = tailStreamSpec;
tailStreamSpec->Stream = tempFile.OutStream;
@@ -117,7 +117,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
HRESULT result;
switch (operation)
switch ((int)operation)
{
case AGENT_OP_Delete:
result = _agentSpec->DeleteItems(tailStream, indices, numItems, updateCallback100);
@@ -149,18 +149,18 @@ HRESULT CAgentFolder::CommonUpdateOperation(
return E_FAIL;
}
RINOK(result);
RINOK(result)
}
_agentSpec->KeepModeForNextOpen();
_agentSpec->Close();
_agent->Close();
// before 9.26: if there was error for MoveToOriginal archive was closed.
// now: we reopen archive after close
// m_FolderItem = NULL;
HRESULT res = tempFile.MoveToOriginal(true);
const HRESULT res = tempFile.MoveToOriginal(true);
// RINOK(res);
if (res == S_OK)
@@ -185,7 +185,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
CMyComPtr<IArchiveOpenCallback> openCallback;
if (updateCallback100)
updateCallback100->QueryInterface(IID_IArchiveOpenCallback, (void **)&openCallback);
RINOK(_agentSpec->ReOpen(openCallback));
RINOK(_agent->ReOpen(openCallback))
}
// CAgent::ReOpen() deletes _proxy and _proxy2
@@ -199,7 +199,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
// ---------- Restore FolderItem ----------
CMyComPtr<IFolderFolder> archiveFolder;
RINOK(_agentSpec->BindToRootFolder(&archiveFolder));
RINOK(_agent->BindToRootFolder(&archiveFolder))
// CAgent::BindToRootFolder() changes _proxy and _proxy2
_proxy = _agentSpec->_proxy;
@@ -209,10 +209,10 @@ HRESULT CAgentFolder::CommonUpdateOperation(
{
FOR_VECTOR (i, pathParts)
{
int next = _proxy->FindSubDir(_proxyDirIndex, pathParts[i]);
const int next = _proxy->FindSubDir(_proxyDirIndex, pathParts[i]);
if (next == -1)
break;
_proxyDirIndex = next;
_proxyDirIndex = (unsigned)next;
}
}
@@ -224,19 +224,19 @@ HRESULT CAgentFolder::CommonUpdateOperation(
}
else FOR_VECTOR (i, pathParts)
{
bool dirOnly = (i + 1 < pathParts.Size() || !isAltStreamFolder);
int index = _proxy2->FindItem(_proxyDirIndex, pathParts[i], dirOnly);
const bool dirOnly = (i + 1 < pathParts.Size() || !isAltStreamFolder);
const int index = _proxy2->FindItem(_proxyDirIndex, pathParts[i], dirOnly);
if (index == -1)
break;
const CProxyFile2 &file = _proxy2->Files[_proxy2->Dirs[_proxyDirIndex].Items[index]];
if (dirOnly)
_proxyDirIndex = file.DirIndex;
_proxyDirIndex = (unsigned)file.DirIndex;
else
{
if (file.AltDirIndex != -1)
_proxyDirIndex = file.AltDirIndex;
_proxyDirIndex = (unsigned)file.AltDirIndex;
break;
}
}
@@ -295,7 +295,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
{
UString s2 ("Error: ");
s2 += s;
RINOK(updateCallback100->UpdateErrorMessage(s2));
RINOK(updateCallback100->UpdateErrorMessage(s2))
return E_FAIL;
}
throw;
@@ -303,16 +303,15 @@ HRESULT CAgentFolder::CommonUpdateOperation(
}
STDMETHODIMP CAgentFolder::CopyFrom(Int32 moveMode,
const wchar_t *fromFolderPath, // test it
Z7_COM7F_IMF(CAgentFolder::CopyFrom(Int32 moveMode,
const wchar_t *fromFolderPath, /* test it */
const wchar_t * const *itemsPaths,
UInt32 numItems,
IProgress *progress)
IProgress *progress))
{
COM_TRY_BEGIN
{
RINOK(_agentSpec->SetFiles(fromFolderPath, itemsPaths, numItems));
RINOK(_agentSpec->SetFiles(fromFolderPath, itemsPaths, numItems))
return CommonUpdateOperation(AGENT_OP_Uni, (moveMode != 0), NULL,
&NUpdateArchive::k_ActionSet_Add,
NULL, 0, progress);
@@ -320,7 +319,7 @@ STDMETHODIMP CAgentFolder::CopyFrom(Int32 moveMode,
COM_TRY_END
}
STDMETHODIMP CAgentFolder::CopyFromFile(UInt32 destIndex, const wchar_t *itemPath, IProgress *progress)
Z7_COM7F_IMF(CAgentFolder::CopyFromFile(UInt32 destIndex, const wchar_t *itemPath, IProgress *progress))
{
COM_TRY_BEGIN
return CommonUpdateOperation(AGENT_OP_CopyFromFile, false, itemPath,
@@ -329,7 +328,7 @@ STDMETHODIMP CAgentFolder::CopyFromFile(UInt32 destIndex, const wchar_t *itemPat
COM_TRY_END
}
STDMETHODIMP CAgentFolder::Delete(const UInt32 *indices, UInt32 numItems, IProgress *progress)
Z7_COM7F_IMF(CAgentFolder::Delete(const UInt32 *indices, UInt32 numItems, IProgress *progress))
{
COM_TRY_BEGIN
return CommonUpdateOperation(AGENT_OP_Delete, false, NULL,
@@ -337,7 +336,7 @@ STDMETHODIMP CAgentFolder::Delete(const UInt32 *indices, UInt32 numItems, IProgr
COM_TRY_END
}
STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress)
Z7_COM7F_IMF(CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress))
{
COM_TRY_BEGIN
@@ -359,7 +358,7 @@ STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress
COM_TRY_END
}
STDMETHODIMP CAgentFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress)
Z7_COM7F_IMF(CAgentFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress))
{
COM_TRY_BEGIN
return CommonUpdateOperation(AGENT_OP_Rename, false, newName, NULL,
@@ -367,13 +366,13 @@ STDMETHODIMP CAgentFolder::Rename(UInt32 index, const wchar_t *newName, IProgres
COM_TRY_END
}
STDMETHODIMP CAgentFolder::CreateFile(const wchar_t * /* name */, IProgress * /* progress */)
Z7_COM7F_IMF(CAgentFolder::CreateFile(const wchar_t * /* name */, IProgress * /* progress */))
{
return E_NOTIMPL;
}
STDMETHODIMP CAgentFolder::SetProperty(UInt32 index, PROPID propID,
const PROPVARIANT *value, IProgress *progress)
Z7_COM7F_IMF(CAgentFolder::SetProperty(UInt32 index, PROPID propID,
const PROPVARIANT *value, IProgress *progress))
{
COM_TRY_BEGIN
if (propID != kpidComment || value->vt != VT_BSTR)

View File

@@ -1,7 +1,7 @@
// IFolderArchive.h
#ifndef __IFOLDER_ARCHIVE_H
#define __IFOLDER_ARCHIVE_H
#ifndef ZIP7_INC_IFOLDER_ARCHIVE_H
#define ZIP7_INC_IFOLDER_ARCHIVE_H
#include "../../../Common/MyString.h"
@@ -12,8 +12,7 @@
#include "../Common/ExtractMode.h"
#include "../Common/IFileExtractCallback.h"
#define FOLDER_ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 0x01, x)
#define FOLDER_ARCHIVE_INTERFACE(i, x) FOLDER_ARCHIVE_INTERFACE_SUB(i, IUnknown, x)
Z7_PURE_INTERFACES_BEGIN
/* ---------- IArchiveFolder ----------
IArchiveFolder is implemented by CAgentFolder (Agent/Agent.h)
@@ -24,19 +23,16 @@ IArchiveFolder is used by:
CPlugin::ExtractFiles
*/
#define INTERFACE_IArchiveFolder(x) \
STDMETHOD(Extract)(const UInt32 *indices, UInt32 numItems, \
#define Z7_IFACEM_IArchiveFolder(x) \
x(Extract(const UInt32 *indices, UInt32 numItems, \
Int32 includeAltStreams, \
Int32 replaceAltStreamCharsMode, \
NExtract::NPathMode::EEnum pathMode, \
NExtract::NOverwriteMode::EEnum overwriteMode, \
const wchar_t *path, Int32 testMode, \
IFolderArchiveExtractCallback *extractCallback2) x; \
IFolderArchiveExtractCallback *extractCallback2)) \
FOLDER_ARCHIVE_INTERFACE(IArchiveFolder, 0x0D)
{
INTERFACE_IArchiveFolder(PURE)
};
Z7_IFACE_CONSTR_FOLDERARC(IArchiveFolder, 0x0D)
/* ---------- IInFolderArchive ----------
@@ -44,85 +40,68 @@ IInFolderArchive is implemented by CAgent (Agent/Agent.h)
IInFolderArchive Is used by FAR/Plugin
*/
#define INTERFACE_IInFolderArchive(x) \
STDMETHOD(Open)(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, BSTR *archiveTypeRes, IArchiveOpenCallback *openArchiveCallback) x; \
STDMETHOD(ReOpen)(IArchiveOpenCallback *openArchiveCallback) x; \
STDMETHOD(Close)() x; \
STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
STDMETHOD(BindToRootFolder)(IFolderFolder **resultFolder) x; \
STDMETHOD(Extract)(NExtract::NPathMode::EEnum pathMode, \
#define Z7_IFACEM_IInFolderArchive(x) \
x(Open(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, BSTR *archiveTypeRes, IArchiveOpenCallback *openArchiveCallback)) \
x(ReOpen(IArchiveOpenCallback *openArchiveCallback)) \
x(Close()) \
x(GetNumberOfProperties(UInt32 *numProperties)) \
x(GetPropertyInfo(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType)) \
x(BindToRootFolder(IFolderFolder **resultFolder)) \
x(Extract(NExtract::NPathMode::EEnum pathMode, \
NExtract::NOverwriteMode::EEnum overwriteMode, const wchar_t *path, \
Int32 testMode, IFolderArchiveExtractCallback *extractCallback2) x; \
Int32 testMode, IFolderArchiveExtractCallback *extractCallback2)) \
FOLDER_ARCHIVE_INTERFACE(IInFolderArchive, 0x0E)
{
INTERFACE_IInFolderArchive(PURE)
};
Z7_IFACE_CONSTR_FOLDERARC(IInFolderArchive, 0x0E)
#define INTERFACE_IFolderArchiveUpdateCallback(x) \
STDMETHOD(CompressOperation)(const wchar_t *name) x; \
STDMETHOD(DeleteOperation)(const wchar_t *name) x; \
STDMETHOD(OperationResult)(Int32 opRes) x; \
STDMETHOD(UpdateErrorMessage)(const wchar_t *message) x; \
STDMETHOD(SetNumFiles)(UInt64 numFiles) x; \
#define Z7_IFACEM_IFolderArchiveUpdateCallback(x) \
x(CompressOperation(const wchar_t *name)) \
x(DeleteOperation(const wchar_t *name)) \
x(OperationResult(Int32 opRes)) \
x(UpdateErrorMessage(const wchar_t *message)) \
x(SetNumFiles(UInt64 numFiles)) \
FOLDER_ARCHIVE_INTERFACE_SUB(IFolderArchiveUpdateCallback, IProgress, 0x0B)
{
INTERFACE_IFolderArchiveUpdateCallback(PURE)
};
Z7_IFACE_CONSTR_FOLDERARC_SUB(IFolderArchiveUpdateCallback, IProgress, 0x0B)
#define INTERFACE_IOutFolderArchive(x) \
STDMETHOD(SetFolder)(IFolderFolder *folder) x; \
STDMETHOD(SetFiles)(const wchar_t *folderPrefix, const wchar_t * const *names, UInt32 numNames) x; \
STDMETHOD(DeleteItems)(ISequentialOutStream *outArchiveStream, \
const UInt32 *indices, UInt32 numItems, IFolderArchiveUpdateCallback *updateCallback) x; \
STDMETHOD(DoOperation)( \
#define Z7_IFACEM_IOutFolderArchive(x) \
x(SetFolder(IFolderFolder *folder)) \
x(SetFiles(const wchar_t *folderPrefix, const wchar_t * const *names, UInt32 numNames)) \
x(DeleteItems(ISequentialOutStream *outArchiveStream, \
const UInt32 *indices, UInt32 numItems, IFolderArchiveUpdateCallback *updateCallback)) \
x(DoOperation( \
FStringVector *requestedPaths, \
FStringVector *processedPaths, \
CCodecs *codecs, int index, \
ISequentialOutStream *outArchiveStream, const Byte *stateActions, const wchar_t *sfxModule, \
IFolderArchiveUpdateCallback *updateCallback) x; \
STDMETHOD(DoOperation2)( \
IFolderArchiveUpdateCallback *updateCallback)) \
x(DoOperation2( \
FStringVector *requestedPaths, \
FStringVector *processedPaths, \
ISequentialOutStream *outArchiveStream, const Byte *stateActions, const wchar_t *sfxModule, \
IFolderArchiveUpdateCallback *updateCallback) x; \
IFolderArchiveUpdateCallback *updateCallback)) \
FOLDER_ARCHIVE_INTERFACE(IOutFolderArchive, 0x0F)
{
INTERFACE_IOutFolderArchive(PURE)
};
Z7_IFACE_CONSTR_FOLDERARC(IOutFolderArchive, 0x0F)
#define INTERFACE_IFolderArchiveUpdateCallback2(x) \
STDMETHOD(OpenFileError)(const wchar_t *path, HRESULT errorCode) x; \
STDMETHOD(ReadingFileError)(const wchar_t *path, HRESULT errorCode) x; \
STDMETHOD(ReportExtractResult)(Int32 opRes, Int32 isEncrypted, const wchar_t *path) x; \
STDMETHOD(ReportUpdateOperation)(UInt32 notifyOp, const wchar_t *path, Int32 isDir) x; \
#define Z7_IFACEM_IFolderArchiveUpdateCallback2(x) \
x(OpenFileError(const wchar_t *path, HRESULT errorCode)) \
x(ReadingFileError(const wchar_t *path, HRESULT errorCode)) \
x(ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *path)) \
x(ReportUpdateOperation(UInt32 notifyOp, const wchar_t *path, Int32 isDir)) \
FOLDER_ARCHIVE_INTERFACE(IFolderArchiveUpdateCallback2, 0x10)
{
INTERFACE_IFolderArchiveUpdateCallback2(PURE)
};
Z7_IFACE_CONSTR_FOLDERARC(IFolderArchiveUpdateCallback2, 0x10)
#define INTERFACE_IFolderScanProgress(x) \
STDMETHOD(ScanError)(const wchar_t *path, HRESULT errorCode) x; \
STDMETHOD(ScanProgress)(UInt64 numFolders, UInt64 numFiles, UInt64 totalSize, const wchar_t *path, Int32 isDir) x; \
#define Z7_IFACEM_IFolderScanProgress(x) \
x(ScanError(const wchar_t *path, HRESULT errorCode)) \
x(ScanProgress(UInt64 numFolders, UInt64 numFiles, UInt64 totalSize, const wchar_t *path, Int32 isDir)) \
FOLDER_ARCHIVE_INTERFACE(IFolderScanProgress, 0x11)
{
INTERFACE_IFolderScanProgress(PURE)
};
Z7_IFACE_CONSTR_FOLDERARC(IFolderScanProgress, 0x11)
#define INTERFACE_IFolderSetZoneIdMode(x) \
STDMETHOD(SetZoneIdMode)(NExtract::NZoneIdMode::EEnum zoneMode) x; \
#define Z7_IFACEM_IFolderSetZoneIdMode(x) \
x(SetZoneIdMode(NExtract::NZoneIdMode::EEnum zoneMode)) \
FOLDER_ARCHIVE_INTERFACE(IFolderSetZoneIdMode, 0x12)
{
INTERFACE_IFolderSetZoneIdMode(PURE)
};
Z7_IFACE_CONSTR_FOLDERARC(IFolderSetZoneIdMode, 0x12)
Z7_PURE_INTERFACES_END
#endif

View File

@@ -1,8 +1,11 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#ifndef ZIP7_INC_STDAFX_H
#define ZIP7_INC_STDAFX_H
#if defined(_MSC_VER) && _MSC_VER >= 1800
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "../../../Common/Common.h"
#endif

View File

@@ -71,12 +71,12 @@ HRESULT CUpdateCallbackAgent::Finalize()
HRESULT CUpdateCallbackAgent::OpenFileError(const FString &path, DWORD systemError)
{
HRESULT hres = HRESULT_FROM_WIN32(systemError);
const HRESULT hres = HRESULT_FROM_WIN32(systemError);
// if (systemError == ERROR_SHARING_VIOLATION)
{
if (Callback2)
{
RINOK(Callback2->OpenFileError(fs2us(path), hres));
RINOK(Callback2->OpenFileError(fs2us(path), hres))
return S_FALSE;
}
@@ -86,7 +86,7 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const FString &path, DWORD systemErr
s += NError::MyFormatMessage(systemError);
s += ": ";
s += fs2us(path);
RINOK(Callback->UpdateErrorMessage(s));
RINOK(Callback->UpdateErrorMessage(s))
return S_FALSE;
}
}
@@ -96,13 +96,13 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const FString &path, DWORD systemErr
HRESULT CUpdateCallbackAgent::ReadingFileError(const FString &path, DWORD systemError)
{
HRESULT hres = HRESULT_FROM_WIN32(systemError);
const HRESULT hres = HRESULT_FROM_WIN32(systemError);
// if (systemError == ERROR_SHARING_VIOLATION)
{
if (Callback2)
{
RINOK(Callback2->ReadingFileError(fs2us(path), hres));
RINOK(Callback2->ReadingFileError(fs2us(path), hres))
}
else if (Callback)
{
@@ -110,7 +110,7 @@ HRESULT CUpdateCallbackAgent::ReadingFileError(const FString &path, DWORD system
s += NError::MyFormatMessage(systemError);
s += ": ";
s += fs2us(path);
RINOK(Callback->UpdateErrorMessage(s));
RINOK(Callback->UpdateErrorMessage(s))
}
}
// FailedFiles.Add(name);
@@ -164,12 +164,12 @@ HRESULT CUpdateCallbackAgent::ReportUpdateOperation(UInt32 op, const wchar_t *na
/*
HRESULT CUpdateCallbackAgent::SetPassword(const UString &
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
password
#endif
)
{
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
PasswordIsDefined = true;
Password = password;
#endif

View File

@@ -1,15 +1,15 @@
// UpdateCallbackAgent.h
#ifndef __UPDATE_CALLBACK_AGENT_H
#define __UPDATE_CALLBACK_AGENT_H
#ifndef ZIP7_INC_UPDATE_CALLBACK_AGENT_H
#define ZIP7_INC_UPDATE_CALLBACK_AGENT_H
#include "../Common/UpdateCallback.h"
#include "IFolderArchive.h"
class CUpdateCallbackAgent: public IUpdateCallbackUI
class CUpdateCallbackAgent Z7_final: public IUpdateCallbackUI
{
INTERFACE_IUpdateCallbackUI(;)
Z7_IFACE_IMP(IUpdateCallbackUI)
CMyComPtr<ICryptoGetTextPassword2> _cryptoGetTextPassword;
CMyComPtr<IFolderArchiveUpdateCallback> Callback;