Update to 7-Zip Version 22.00

See: https://sourceforge.net/p/sevenzip/discussion/45797/thread/9c2d9061ce/
This commit is contained in:
Tino Reichardt
2022-08-07 09:59:33 +02:00
parent 6a4fe97fc3
commit 57558682a8
211 changed files with 15251 additions and 2482 deletions

View File

@@ -25,6 +25,10 @@ using namespace NWindows;
CCodecs *g_CodecsObj;
static const bool k_keepEmptyDirPrefixes =
false; // 22.00
// true; // 21.07
#ifdef EXTERNAL_CODECS
CExternalCodecs g_ExternalCodecs;
const CExternalCodecs *g_ExternalCodecs_Ptr;
@@ -114,9 +118,9 @@ void CAgentFolder::LoadFolder(unsigned proxyDirIndex)
item.Index = i;
_items.Add(item);
const CProxyFile2 &file = _proxy2->Files[dir.Items[i]];
if (file.DirIndex >= 0)
if (file.DirIndex != -1)
LoadFolder(file.DirIndex);
if (_loadAltStreams && file.AltDirIndex >= 0)
if (_loadAltStreams && file.AltDirIndex != -1)
LoadFolder(file.AltDirIndex);
}
return;
@@ -211,21 +215,21 @@ void CAgentFolder::GetPrefix(UInt32 index, UString &prefix) const
unsigned len = 0;
while (proxyIndex != _proxyDirIndex && proxyIndex >= k_Proxy2_NumRootDirs)
{
const CProxyFile2 &file = _proxy2->Files[_proxy2->Dirs[proxyIndex].ArcIndex];
const CProxyFile2 &file = _proxy2->Files[(unsigned)_proxy2->Dirs[proxyIndex].ArcIndex];
len += file.NameLen + 1;
proxyIndex = (file.Parent < 0) ? 0 : _proxy2->Files[file.Parent].GetDirIndex(file.IsAltStream);
proxyIndex = (file.Parent == -1) ? 0 : _proxy2->Files[(unsigned)file.Parent].GetDirIndex(file.IsAltStream);
}
wchar_t *p = prefix.GetBuf_SetEnd(len) + len;
proxyIndex = item.DirIndex;
while (proxyIndex != _proxyDirIndex && proxyIndex >= k_Proxy2_NumRootDirs)
{
const CProxyFile2 &file = _proxy2->Files[_proxy2->Dirs[proxyIndex].ArcIndex];
const CProxyFile2 &file = _proxy2->Files[(unsigned)_proxy2->Dirs[proxyIndex].ArcIndex];
p--;
*p = WCHAR_PATH_SEPARATOR;
p -= file.NameLen;
wmemcpy(p, file.Name, file.NameLen);
proxyIndex = (file.Parent < 0) ? 0 : _proxy2->Files[file.Parent].GetDirIndex(file.IsAltStream);
proxyIndex = (file.Parent == -1) ? 0 : _proxy2->Files[(unsigned)file.Parent].GetDirIndex(file.IsAltStream);
}
}
else
@@ -327,7 +331,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT
/*
if (propID == kpidNumAltStreams)
{
if (item.AltDirIndex >= 0)
if (item.AltDirIndex != -1)
prop = _proxy2->Dirs[item.AltDirIndex].Items.Size();
}
else
@@ -887,12 +891,12 @@ STDMETHODIMP CAgentFolder::BindToFolder(const wchar_t *name, IFolderFolder **res
if (_proxy2)
{
int index = _proxy2->FindItem(_proxyDirIndex, name, true);
if (index < 0)
if (index == -1)
return E_INVALIDARG;
return BindToFolder_Internal(_proxy2->Files[_proxy2->Dirs[_proxyDirIndex].Items[index]].DirIndex, resultFolder);
}
int index = _proxy->FindSubDir(_proxyDirIndex, name);
if (index < 0)
if (index == -1)
return E_INVALIDARG;
return BindToFolder_Internal(index, resultFolder);
COM_TRY_END
@@ -956,7 +960,7 @@ STDMETHODIMP CAgentFolder::BindToAltStreams(UInt32 index, IFolderFolder **result
{
unsigned arcIndex = _proxy2->Dirs[_proxyDirIndex].ArcIndex;
const CProxyFile2 &item = _proxy2->Files[arcIndex];
if (item.AltDirIndex < 0)
if (item.AltDirIndex == -1)
return S_OK;
altDirIndex = item.AltDirIndex;
// parentFolder = _parentFolder;
@@ -972,7 +976,7 @@ STDMETHODIMP CAgentFolder::BindToAltStreams(UInt32 index, IFolderFolder **result
SET_realIndex_AND_dir_2
unsigned arcIndex = dir->Items[realIndex];
const CProxyFile2 &item = _proxy2->Files[arcIndex];
if (item.AltDirIndex < 0)
if (item.AltDirIndex == -1)
return S_OK;
return BindToAltStreams_Internal(item.AltDirIndex, resultFolder);
}
@@ -1000,7 +1004,7 @@ STDMETHODIMP CAgentFolder::BindToAltStreams(const wchar_t *name, IFolderFolder *
FOR_VECTOR (i, dir.Items)
{
const CProxyFile2 &file = _proxy2->Files[dir.Items[i]];
if (file.AltDirIndex >= 0)
if (file.AltDirIndex != -1)
if (CompareFileNames(file.Name, name) == 0)
return BindToAltStreams_Internal(file.AltDirIndex, resultFolder);
}
@@ -1036,7 +1040,7 @@ STDMETHODIMP CAgentFolder::AreAltStreamsSupported(UInt32 index, Int32 *isSupport
arcIndex = dir->Items[realIndex];
}
if (_proxy2->Files[arcIndex].AltDirIndex >= 0)
if (_proxy2->Files[arcIndex].AltDirIndex != -1)
*isSupported = BoolToInt(true);
return S_OK;
}
@@ -1062,18 +1066,18 @@ STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
else
{
const CProxyDir2 &fold = _proxy2->Dirs[_proxyDirIndex];
const CProxyFile2 &file = _proxy2->Files[fold.ArcIndex];
int parentIndex = file.Parent;
if (parentIndex < 0)
const CProxyFile2 &file = _proxy2->Files[(unsigned)fold.ArcIndex];
const int parentIndex = file.Parent;
if (parentIndex == -1)
proxyDirIndex = k_Proxy2_RootDirIndex;
else
proxyDirIndex = _proxy2->Files[parentIndex].DirIndex;
proxyDirIndex = _proxy2->Files[(unsigned)parentIndex].DirIndex;
}
}
else
{
int parent = _proxy->Dirs[_proxyDirIndex].ParentDir;
if (parent < 0)
if (parent == -1)
return S_OK;
proxyDirIndex = parent;
}
@@ -1239,8 +1243,8 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
const CProxyDir2 &dir = _proxy2->Dirs[_proxyDirIndex];
if (propID == kpidName)
{
if (dir.ArcIndex >= 0)
prop = _proxy2->Files[dir.ArcIndex].Name;
if (dir.ArcIndex != -1)
prop = _proxy2->Files[(unsigned)dir.ArcIndex].Name;
}
else if (propID == kpidPath)
{
@@ -1477,8 +1481,8 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
false, // multiArchives
pathMode,
overwriteMode,
true // keepEmptyDirPrefixes
);
_zoneMode,
k_keepEmptyDirPrefixes);
if (extractCallback2)
extractCallback2->SetTotal(_agentSpec->GetArc().GetEstmatedPhySize());
@@ -1500,6 +1504,15 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
extractNtOptions.ReplaceColonForAltStream = IntToBool(replaceAltStreamColon);
extractCallbackSpec->InitBeforeNewArchive();
#if defined(_WIN32) && !defined(UNDER_CE)
if (_zoneMode != NExtract::NZoneIdMode::kNone)
{
ReadZoneFile_Of_BaseFile(us2fs(_agentSpec->_archiveFilePath), extractCallbackSpec->ZoneBuf);
}
#endif
extractCallbackSpec->Init(
extractNtOptions,
NULL, &_agentSpec->GetArc(),
@@ -1645,8 +1658,8 @@ STDMETHODIMP CAgent::Open(
CArc &arc = _archiveLink.Arcs.Back();
if (!inStream)
{
arc.MTimeDefined = !fi.IsDevice;
arc.MTime = fi.MTime;
arc.MTime.Set_From_FiTime(fi.MTime);
arc.MTime.Def = !fi.IsDevice;
}
ArchiveType = GetTypeOfArc(arc);
@@ -1783,8 +1796,8 @@ STDMETHODIMP CAgent::Extract(
false, // multiArchives
pathMode,
overwriteMode,
true // keepEmptyDirPrefixes
);
NExtract::NZoneIdMode::kNone,
k_keepEmptyDirPrefixes);
CExtractNtOptions extractNtOptions;
extractNtOptions.AltStreams.Val = true; // change it!!!

View File

@@ -58,7 +58,7 @@ class CAgentFolder:
public IArchiveFolder,
public IArchiveFolderInternal,
public IInArchiveGetStream,
// public IFolderSetReplaceAltStreamCharsMode,
public IFolderSetZoneIdMode,
#ifdef NEW_FOLDER_INTERFACE
public IFolderOperations,
public IFolderSetFlatMode,
@@ -78,7 +78,7 @@ public:
MY_QUERYINTERFACE_ENTRY(IArchiveFolder)
MY_QUERYINTERFACE_ENTRY(IArchiveFolderInternal)
MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
// MY_QUERYINTERFACE_ENTRY(IFolderSetReplaceAltStreamCharsMode)
MY_QUERYINTERFACE_ENTRY(IFolderSetZoneIdMode)
#ifdef NEW_FOLDER_INTERFACE
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
@@ -92,7 +92,7 @@ public:
void GetRealIndices(const UInt32 *indices, UInt32 numItems,
bool includeAltStreams, bool includeFolderSubItemsInFlatMode, CUIntVector &realIndices) const;
// INTERFACE_FolderSetReplaceAltStreamCharsMode(;)
INTERFACE_IFolderSetZoneIdMode(;)
INTERFACE_FolderFolder(;)
INTERFACE_FolderAltStreams(;)
@@ -123,6 +123,7 @@ public:
_isAltStreamFolder(false),
_flatMode(false),
_loadAltStreams(false) // _loadAltStreams alt streams works in flat mode, but we don't use it now
, _zoneMode(NExtract::NZoneIdMode::kNone)
/* , _replaceAltStreamCharsMode(0) */
{}
@@ -169,6 +170,7 @@ public:
bool _flatMode;
bool _loadAltStreams; // in Flat mode
// Int32 _replaceAltStreamCharsMode;
NExtract::NZoneIdMode::EEnum _zoneMode;
};
class CAgent:

View File

@@ -12,6 +12,8 @@
#include "../../Common/FileStreams.h"
#include "../../Archive/Common/ItemNameUtils.h"
#include "Agent.h"
#include "UpdateCallbackAgent.h"
@@ -67,8 +69,8 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
unsigned arcIndex = item.SubFiles[i];
const CProxyFile &fileItem = agent->_proxy->Files[arcIndex];
CArcItem ai;
RINOK(agent->GetArc().GetItemMTime(arcIndex, ai.MTime, ai.MTimeDefined));
RINOK(agent->GetArc().GetItemSize(arcIndex, ai.Size, ai.SizeDefined));
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
@@ -83,9 +85,9 @@ static HRESULT EnumerateArchiveItems(CAgent *agent,
if (dirItem.IsLeaf())
{
CArcItem ai;
RINOK(agent->GetArc().GetItemMTime(dirItem.ArcIndex, ai.MTime, ai.MTimeDefined));
RINOK(agent->GetArc().GetItem_MTime(dirItem.ArcIndex, ai.MTime));
ai.IsDir = true;
ai.SizeDefined = false;
ai.Size_Defined = false;
ai.Name = fullName;
ai.Censored = true; // test it
ai.IndexInServer = dirItem.ArcIndex;
@@ -111,18 +113,18 @@ static HRESULT EnumerateArchiveItems2(const CAgent *agent,
ai.IndexInServer = arcIndex;
ai.Name = prefix + file.Name;
ai.Censored = true; // test it
RINOK(agent->GetArc().GetItemMTime(arcIndex, ai.MTime, ai.MTimeDefined));
RINOK(agent->GetArc().GetItem_MTime(arcIndex, ai.MTime));
ai.IsDir = file.IsDir();
ai.SizeDefined = false;
ai.Size_Defined = false;
ai.IsAltStream = file.IsAltStream;
if (!ai.IsDir)
{
RINOK(agent->GetArc().GetItemSize(arcIndex, ai.Size, ai.SizeDefined));
RINOK(agent->GetArc().GetItem_Size(arcIndex, ai.Size, ai.Size_Defined));
ai.IsDir = false;
}
arcItems.Add(ai);
if (file.AltDirIndex >= 0)
if (file.AltDirIndex != -1)
{
RINOK(EnumerateArchiveItems2(agent, file.AltDirIndex, ai.Name + L':', arcItems));
}
@@ -264,10 +266,13 @@ STDMETHODIMP CAgent::DoOperation(
#endif
}
NFileTimeType::EEnum fileTimeType;
NFileTimeType::EEnum fileTimeType = NFileTimeType::kNotDefined;
UInt32 value;
RINOK(outArchive->GetFileTimeType(&value));
// we support any future fileType here.
// 22.00:
fileTimeType = (NFileTimeType::EEnum)value;
/*
switch (value)
{
case NFileTimeType::kWindows:
@@ -276,8 +281,11 @@ STDMETHODIMP CAgent::DoOperation(
fileTimeType = NFileTimeType::EEnum(value);
break;
default:
{
return E_FAIL;
}
}
*/
CObjectVector<CArcItem> arcItems;
@@ -389,11 +397,11 @@ STDMETHODIMP CAgent::DoOperation(
FOR_VECTOR(i, updatePairs2)
{
const CUpdatePair2 &up = updatePairs2[i];
if (up.DirIndex >= 0 && up.NewData)
if (up.DirIndex != -1 && up.NewData)
{
const CDirItem &di = dirItems.Items[up.DirIndex];
const CDirItem &di = dirItems.Items[(unsigned)up.DirIndex];
if (!di.IsDir() && di.Size == 0)
processedItems[up.DirIndex] = 1;
processedItems[(unsigned)up.DirIndex] = 1;
}
}
}
@@ -452,7 +460,7 @@ STDMETHODIMP CAgent::DeleteItems(ISequentialOutStream *outArchiveStream,
if (curIndex < realIndices.Size())
if (realIndices[curIndex] == i)
{
RINOK(GetArc().GetItemPath2(i, deletePath));
RINOK(GetArc().GetItem_Path2(i, deletePath));
RINOK(updateCallback100->DeleteOperation(deletePath));
curIndex++;
@@ -548,11 +556,14 @@ HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
true, // includeFolderSubItemsInFlatMode
realIndices);
int mainRealIndex = _agentFolder->GetRealIndex(indices[0]);
UString fullPrefix = _agentFolder->GetFullPrefix(indices[0]);
UString oldItemPath = fullPrefix + _agentFolder->GetName(indices[0]);
UString newItemPath = fullPrefix + newItemName;
const UInt32 ind0 = indices[0];
const int mainRealIndex = _agentFolder->GetRealIndex(ind0);
const UString fullPrefix = _agentFolder->GetFullPrefix(ind0);
UString name = _agentFolder->GetName(ind0);
// 22.00 : we normalize name
NArchive::NItemName::NormalizeSlashes_in_FileName_for_OsPath(name);
const UString oldItemPath = fullPrefix + name;
const UString newItemPath = fullPrefix + newItemName;
UStringVector newNames;
@@ -568,10 +579,10 @@ HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
if (realIndices[curIndex] == i)
{
up2.NewProps = true;
RINOK(GetArc().IsItemAnti(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().GetItemPath2(i, oldFullPath));
RINOK(GetArc().GetItem_Path2(i, oldFullPath));
if (!IsPath1PrefixedByPath2(oldFullPath, oldItemPath))
return E_INVALIDARG;

View File

@@ -18,6 +18,8 @@
#include "../../../Windows/PropVariant.h"
#include "../../../Windows/PropVariantConv.h"
#include "../../Archive/Common/ItemNameUtils.h"
#include "AgentProxy.h"
using namespace NWindows;
@@ -33,12 +35,12 @@ int CProxyArc::FindSubDir(unsigned dirIndex, const wchar_t *name, unsigned &inse
insertPos = left;
return -1;
}
unsigned mid = (left + right) / 2;
unsigned dirIndex2 = subDirs[mid];
int compare = CompareFileNames(name, Dirs[dirIndex2].Name);
if (compare == 0)
const unsigned mid = (unsigned)(((size_t)left + (size_t)right) / 2);
const unsigned dirIndex2 = subDirs[mid];
const int comp = CompareFileNames(name, Dirs[dirIndex2].Name);
if (comp == 0)
return dirIndex2;
if (compare < 0)
if (comp < 0)
right = mid;
else
left = mid + 1;
@@ -67,12 +69,12 @@ unsigned CProxyArc::AddDir(unsigned dirIndex, int arcIndex, const UString &name)
{
unsigned insertPos;
int subDirIndex = FindSubDir(dirIndex, name, insertPos);
if (subDirIndex >= 0)
if (subDirIndex != -1)
{
if (arcIndex >= 0)
if (arcIndex != -1)
{
CProxyDir &item = Dirs[subDirIndex];
if (item.ArcIndex < 0)
CProxyDir &item = Dirs[(unsigned)subDirIndex];
if (item.ArcIndex == -1)
item.ArcIndex = arcIndex;
}
return subDirIndex;
@@ -98,27 +100,31 @@ void CProxyDir::Clear()
void CProxyArc::GetDirPathParts(int dirIndex, UStringVector &pathParts) const
{
pathParts.Clear();
while (dirIndex >= 0)
while (dirIndex != -1)
{
const CProxyDir &dir = Dirs[dirIndex];
dirIndex = dir.ParentDir;
if (dirIndex < 0)
if (dirIndex == -1)
break;
pathParts.Insert(0, dir.Name);
// 22.00: we normalize name
NArchive::NItemName::NormalizeSlashes_in_FileName_for_OsPath(pathParts[0]);
}
}
UString CProxyArc::GetDirPath_as_Prefix(int dirIndex) const
{
UString s;
while (dirIndex >= 0)
while (dirIndex != -1)
{
const CProxyDir &dir = Dirs[dirIndex];
dirIndex = dir.ParentDir;
if (dirIndex < 0)
if (dirIndex == -1)
break;
s.InsertAtFront(WCHAR_PATH_SEPARATOR);
s.Insert(0, dir.Name);
// 22.00: we normalize name
NArchive::NItemName::NormalizeSlashes_in_FileName_for_OsPath(s.GetBuf(), MyStringLen(dir.Name));
}
return s;
}
@@ -251,7 +257,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
{
if (progress && (i & 0xFFFF) == 0)
{
UInt64 currentItemIndex = i;
const UInt64 currentItemIndex = i;
RINOK(progress->SetCompleted(&currentItemIndex));
}
@@ -259,9 +265,9 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
unsigned len = 0;
bool isPtrName = false;
#if WCHAR_PATH_SEPARATOR != L'/'
wchar_t replaceFromChar = 0;
#endif
#if WCHAR_PATH_SEPARATOR != L'/'
wchar_t separatorChar = WCHAR_PATH_SEPARATOR;
#endif
#if defined(MY_CPU_LE) && defined(_WIN32)
// it works only if (sizeof(wchar_t) == 2)
@@ -278,9 +284,9 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
len = size / 2 - 1;
s = (const wchar_t *)p;
isPtrName = true;
#if WCHAR_PATH_SEPARATOR != L'/'
replaceFromChar = L'\\';
#endif
#if WCHAR_PATH_SEPARATOR != L'/'
separatorChar = L'/'; // 0
#endif
}
}
if (!s)
@@ -297,7 +303,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
return E_FAIL;
if (len == 0)
{
RINOK(arc.GetDefaultItemPath(i, path));
RINOK(arc.GetItem_DefaultPath(i, path));
len = path.Len();
s = path;
}
@@ -328,16 +334,12 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
for (unsigned j = 0; j < len; j++)
{
const wchar_t c = s[j];
if (c == WCHAR_PATH_SEPARATOR || c == L'/')
{
if (c == L'/'
#if WCHAR_PATH_SEPARATOR != L'/'
if (c == replaceFromChar)
{
// s.ReplaceOneCharAtPos(j, WCHAR_IN_FILE_NAME_BACKSLASH_REPLACEMENT);
continue;
}
|| (c == separatorChar)
#endif
)
{
const unsigned kLevelLimit = 1 << 10;
if (numLevels <= kLevelLimit)
{
@@ -345,6 +347,8 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
name = "[LONG_PATH]";
else
name.SetFrom(s + namePos, j - namePos);
// 22.00: we can normalize dir here
// NArchive::NItemName::NormalizeSlashes_in_FileName_for_OsPath(name);
curItem = AddDir(curItem, -1, name);
}
namePos = j + 1;
@@ -384,6 +388,8 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
if (isDir)
{
name = s;
// 22.00: we can normalize dir here
// NArchive::NItemName::NormalizeSlashes_in_FileName_for_OsPath(name);
AddDir(curItem, (int)i, name);
}
else
@@ -418,14 +424,14 @@ void CProxyArc2::GetDirPathParts(int dirIndex, UStringVector &pathParts, bool &i
while (dirIndex >= (int)k_Proxy2_NumRootDirs)
{
const CProxyDir2 &dir = Dirs[dirIndex];
const CProxyFile2 &file = Files[dir.ArcIndex];
const CProxyFile2 &file = Files[(unsigned)dir.ArcIndex];
if (pathParts.IsEmpty() && dirIndex == file.AltDirIndex)
isAltStreamDir = true;
pathParts.Insert(0, file.Name);
int par = file.Parent;
if (par < 0)
if (par == -1)
break;
dirIndex = Files[par].DirIndex;
dirIndex = Files[(unsigned)par].DirIndex;
}
}
@@ -436,7 +442,7 @@ bool CProxyArc2::IsAltDir(unsigned dirIndex) const
if (dirIndex == k_Proxy2_AltRootDirIndex)
return true;
const CProxyDir2 &dir = Dirs[dirIndex];
const CProxyFile2 &file = Files[dir.ArcIndex];
const CProxyFile2 &file = Files[(unsigned)dir.ArcIndex];
return ((int)dirIndex == file.AltDirIndex);
}
@@ -448,7 +454,7 @@ UString CProxyArc2::GetDirPath_as_Prefix(unsigned dirIndex, bool &isAltStreamDir
isAltStreamDir = true;
else if (dirIndex >= k_Proxy2_NumRootDirs)
{
const CProxyFile2 &file = Files[dir.ArcIndex];
const CProxyFile2 &file = Files[(unsigned)dir.ArcIndex];
isAltStreamDir = ((int)dirIndex == file.AltDirIndex);
}
return dir.PathPrefix;
@@ -458,9 +464,9 @@ void CProxyArc2::AddRealIndices_of_ArcItem(unsigned arcIndex, bool includeAltStr
{
realIndices.Add(arcIndex);
const CProxyFile2 &file = Files[arcIndex];
if (file.DirIndex >= 0)
if (file.DirIndex != -1)
AddRealIndices_of_Dir(file.DirIndex, includeAltStreams, realIndices);
if (includeAltStreams && file.AltDirIndex >= 0)
if (includeAltStreams && file.AltDirIndex != -1)
AddRealIndices_of_Dir(file.AltDirIndex, includeAltStreams, realIndices);
}
@@ -520,15 +526,18 @@ void CProxyArc2::CalculateSizes(unsigned dirIndex, IInArchive *archive)
}
const CProxyFile2 &subFile = Files[index];
if (subFile.DirIndex < 0)
if (subFile.DirIndex == -1)
{
dir.NumSubFiles++;
}
else
{
// 22.00: we normalize name
UString s = subFile.Name;
NArchive::NItemName::NormalizeSlashes_in_FileName_for_OsPath(s);
dir.NumSubDirs++;
CProxyDir2 &f = Dirs[subFile.DirIndex];
f.PathPrefix = dir.PathPrefix + subFile.Name + WCHAR_PATH_SEPARATOR;
f.PathPrefix = dir.PathPrefix + s + WCHAR_PATH_SEPARATOR;
CalculateSizes(subFile.DirIndex, archive);
dir.Size += f.Size;
dir.PackSize += f.PackSize;
@@ -539,7 +548,7 @@ void CProxyArc2::CalculateSizes(unsigned dirIndex, IInArchive *archive)
dir.CrcIsDefined = false;
}
if (subFile.AltDirIndex < 0)
if (subFile.AltDirIndex == -1)
{
// dir.NumSubFiles++;
}
@@ -688,12 +697,12 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
if (file.IsAltStream)
{
if (file.Parent < 0)
if (file.Parent == -1)
dirIndex = k_Proxy2_AltRootDirIndex;
else
{
int &folderIndex2 = Files[file.Parent].AltDirIndex;
if (folderIndex2 < 0)
int &folderIndex2 = Files[(unsigned)file.Parent].AltDirIndex;
if (folderIndex2 == -1)
{
folderIndex2 = Dirs.Size();
CProxyDir2 &dir = Dirs.AddNew();
@@ -704,12 +713,12 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
}
else
{
if (file.Parent < 0)
if (file.Parent == -1)
dirIndex = k_Proxy2_RootDirIndex;
else
{
dirIndex = Files[file.Parent].DirIndex;
if (dirIndex < 0)
dirIndex = Files[(unsigned)file.Parent].DirIndex;
if (dirIndex == -1)
return E_FAIL;
}
}
@@ -731,7 +740,7 @@ int CProxyArc2::FindItem(unsigned dirIndex, const wchar_t *name, bool foldersOnl
FOR_VECTOR (i, dir.Items)
{
const CProxyFile2 &file = Files[dir.Items[i]];
if (foldersOnly && file.DirIndex < 0)
if (foldersOnly && file.DirIndex == -1)
continue;
if (CompareFileNames(file.Name, name) == 0)
return i;

View File

@@ -38,7 +38,7 @@ struct CProxyDir
~CProxyDir() { delete [](wchar_t *)(void *)Name; }
void Clear();
bool IsLeaf() const { return ArcIndex >= 0; }
bool IsLeaf() const { return ArcIndex != -1; }
};
class CProxyArc
@@ -82,7 +82,7 @@ struct CProxyFile2
int GetDirIndex(bool forAltStreams) const { return forAltStreams ? AltDirIndex : DirIndex; }
bool IsDir() const { return DirIndex >= 0; }
bool IsDir() const { return DirIndex != -1; }
CProxyFile2():
DirIndex(-1), AltDirIndex(-1), Parent(-1),
Name(NULL), NameLen(0),
@@ -145,7 +145,7 @@ public:
{
const CProxyFile2 &file = Files[arcIndex];
if (file.Parent < 0)
if (file.Parent == -1)
return file.IsAltStream ?
k_Proxy2_AltRootDirIndex :
k_Proxy2_RootDirIndex;

View File

@@ -16,6 +16,12 @@ STDMETHODIMP CAgentFolder::SetReplaceAltStreamCharsMode(Int32 replaceAltStreamCh
}
*/
STDMETHODIMP CAgentFolder::SetZoneIdMode(NExtract::NZoneIdMode::EEnum zoneMode)
{
_zoneMode = zoneMode;
return S_OK;
}
STDMETHODIMP CAgentFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems,
Int32 includeAltStreams, Int32 replaceAltStreamCharsMode,
const wchar_t *path, IFolderOperationsExtractCallback *callback)

View File

@@ -210,7 +210,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
FOR_VECTOR (i, pathParts)
{
int next = _proxy->FindSubDir(_proxyDirIndex, pathParts[i]);
if (next < 0)
if (next == -1)
break;
_proxyDirIndex = next;
}
@@ -226,7 +226,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
{
bool dirOnly = (i + 1 < pathParts.Size() || !isAltStreamFolder);
int index = _proxy2->FindItem(_proxyDirIndex, pathParts[i], dirOnly);
if (index < 0)
if (index == -1)
break;
const CProxyFile2 &file = _proxy2->Files[_proxy2->Dirs[_proxyDirIndex].Items[index]];
@@ -235,7 +235,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
_proxyDirIndex = file.DirIndex;
else
{
if (file.AltDirIndex >= 0)
if (file.AltDirIndex != -1)
_proxyDirIndex = file.AltDirIndex;
break;
}
@@ -351,7 +351,7 @@ STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress
}
else
{
if (_proxy->FindSubDir(_proxyDirIndex, name) >= 0)
if (_proxy->FindSubDir(_proxyDirIndex, name) != -1)
return ERROR_ALREADY_EXISTS;
}

View File

@@ -116,4 +116,13 @@ FOLDER_ARCHIVE_INTERFACE(IFolderScanProgress, 0x11)
INTERFACE_IFolderScanProgress(PURE)
};
#define INTERFACE_IFolderSetZoneIdMode(x) \
STDMETHOD(SetZoneIdMode)(NExtract::NZoneIdMode::EEnum zoneMode) x; \
FOLDER_ARCHIVE_INTERFACE(IFolderSetZoneIdMode, 0x12)
{
INTERFACE_IFolderSetZoneIdMode(PURE)
};
#endif