mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 01:15:00 -06:00
Update to 7-Zip Version 18.05
This commit is contained in:
@@ -735,6 +735,7 @@ static HRESULT Compress(
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->ShareForWrite = options.OpenShareForWrite;
|
||||
updateCallbackSpec->StopAfterOpenError = options.StopAfterOpenError;
|
||||
updateCallbackSpec->StdInMode = options.StdInMode;
|
||||
updateCallbackSpec->Callback = callback;
|
||||
|
||||
@@ -1045,36 +1046,6 @@ static HRESULT EnumerateInArchiveItems(
|
||||
|
||||
#endif
|
||||
|
||||
struct CRefSortPair
|
||||
{
|
||||
unsigned Len;
|
||||
unsigned Index;
|
||||
};
|
||||
|
||||
#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
|
||||
|
||||
static int CompareRefSortPair(const CRefSortPair *a1, const CRefSortPair *a2, void *)
|
||||
{
|
||||
RINOZ(-MyCompare(a1->Len, a2->Len));
|
||||
return MyCompare(a1->Index, a2->Index);
|
||||
}
|
||||
|
||||
static unsigned GetNumSlashes(const FChar *s)
|
||||
{
|
||||
for (unsigned numSlashes = 0;;)
|
||||
{
|
||||
FChar c = *s++;
|
||||
if (c == 0)
|
||||
return numSlashes;
|
||||
if (IS_PATH_SEPAR(c))
|
||||
numSlashes++;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void ConvertToLongNames(NWildcard::CCensor &censor);
|
||||
#endif
|
||||
|
||||
HRESULT UpdateArchive(
|
||||
CCodecs *codecs,
|
||||
const CObjectVector<COpenType> &types,
|
||||
@@ -1189,6 +1160,16 @@ HRESULT UpdateArchive(
|
||||
throw "there is no such archive";
|
||||
if (fi.IsDevice)
|
||||
return E_NOTIMPL;
|
||||
|
||||
if (!options.StdOutMode && options.UpdateArchiveItself)
|
||||
if (fi.IsReadOnly())
|
||||
{
|
||||
errorInfo.SystemError = ERROR_ACCESS_DENIED;
|
||||
errorInfo.Message = "The file is read-only";
|
||||
errorInfo.FileNames.Add(arcPath);
|
||||
return errorInfo.Get_HRESULT_Error();
|
||||
}
|
||||
|
||||
if (options.VolumesSizes.Size() > 0)
|
||||
{
|
||||
errorInfo.FileNames.Add(us2fs(arcPath));
|
||||
@@ -1509,9 +1490,13 @@ HRESULT UpdateArchive(
|
||||
CArchivePath &ap = options.Commands[0].ArchivePath;
|
||||
const FString &tempPath = ap.GetTempPath();
|
||||
|
||||
// DWORD attrib = 0;
|
||||
if (thereIsInArchive)
|
||||
{
|
||||
// attrib = NFind::GetFileAttrib(us2fs(arcPath));
|
||||
if (!DeleteFileAlways(us2fs(arcPath)))
|
||||
return errorInfo.SetFromLastError("cannot delete the file", us2fs(arcPath));
|
||||
}
|
||||
|
||||
if (!MyMoveFile(tempPath, us2fs(arcPath)))
|
||||
{
|
||||
@@ -1519,6 +1504,15 @@ HRESULT UpdateArchive(
|
||||
errorInfo.FileNames.Add(us2fs(arcPath));
|
||||
return errorInfo.Get_HRESULT_Error();
|
||||
}
|
||||
|
||||
/*
|
||||
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
DWORD attrib2 = NFind::GetFileAttrib(us2fs(arcPath));
|
||||
if (attrib2 != INVALID_FILE_ATTRIBUTES)
|
||||
NDir::SetFileAttrib(us2fs(arcPath), attrib2 | FILE_ATTRIBUTE_READONLY);
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@@ -1608,7 +1602,7 @@ HRESULT UpdateArchive(
|
||||
|
||||
if (options.DeleteAfterCompressing)
|
||||
{
|
||||
CRecordVector<CRefSortPair> pairs;
|
||||
CRecordVector<CDirPathSortPair> pairs;
|
||||
FStringVector foldersNames;
|
||||
|
||||
unsigned i;
|
||||
@@ -1616,12 +1610,12 @@ HRESULT UpdateArchive(
|
||||
for (i = 0; i < dirItems.Items.Size(); i++)
|
||||
{
|
||||
const CDirItem &dirItem = dirItems.Items[i];
|
||||
FString phyPath = dirItems.GetPhyPath(i);
|
||||
const FString phyPath = dirItems.GetPhyPath(i);
|
||||
if (dirItem.IsDir())
|
||||
{
|
||||
CRefSortPair pair;
|
||||
CDirPathSortPair pair;
|
||||
pair.Index = i;
|
||||
pair.Len = GetNumSlashes(phyPath);
|
||||
pair.SetNumSlashes(phyPath);
|
||||
pairs.Add(pair);
|
||||
}
|
||||
else
|
||||
@@ -1654,11 +1648,11 @@ HRESULT UpdateArchive(
|
||||
}
|
||||
}
|
||||
|
||||
pairs.Sort(CompareRefSortPair, NULL);
|
||||
pairs.Sort2();
|
||||
|
||||
for (i = 0; i < pairs.Size(); i++)
|
||||
{
|
||||
FString phyPath = dirItems.GetPhyPath(pairs[i].Index);
|
||||
const FString phyPath = dirItems.GetPhyPath(pairs[i].Index);
|
||||
if (NFind::DoesDirExist(phyPath))
|
||||
{
|
||||
RINOK(callback->DeletingAfterArchiving(phyPath, true));
|
||||
|
||||
Reference in New Issue
Block a user