aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/Common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/7zip/UI/Common/ArchiveExtractCallback.cpp138
-rw-r--r--CPP/7zip/UI/Common/ArchiveExtractCallback.h95
-rw-r--r--CPP/7zip/UI/Common/Bench.cpp48
-rw-r--r--CPP/7zip/UI/Common/EnumDirItems.cpp4
-rw-r--r--CPP/7zip/UI/Common/HashCalc.cpp34
-rw-r--r--CPP/7zip/UI/Common/TempFiles.cpp3
-rw-r--r--CPP/7zip/UI/Common/TempFiles.h3
-rw-r--r--CPP/7zip/UI/Common/Update.cpp68
-rw-r--r--CPP/7zip/UI/Common/Update.h5
-rw-r--r--CPP/7zip/UI/Common/WorkDir.cpp16
-rw-r--r--CPP/7zip/UI/Common/WorkDir.h8
-rw-r--r--CPP/7zip/UI/Common/ZipRegistry.cpp37
12 files changed, 288 insertions, 171 deletions
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
index 2d32694..67ea29c 100644
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -140,21 +140,25 @@ static bool FindExt2(const char *p, const UString &name)
140} 140}
141 141
142 142
143static const FChar * const k_ZoneId_StreamName = FTEXT(":Zone.Identifier"); 143static const char * const k_ZoneId_StreamName_With_Colon_Prefix = ":Zone.Identifier";
144 144
145void ReadZoneFile_Of_BaseFile(CFSTR fileName2, CByteBuffer &buf) 145bool Is_ZoneId_StreamName(const wchar_t *s)
146{ 146{
147 FString fileName (fileName2); 147 return StringsAreEqualNoCase_Ascii(s, k_ZoneId_StreamName_With_Colon_Prefix + 1);
148 fileName += k_ZoneId_StreamName; 148}
149 149
150void ReadZoneFile_Of_BaseFile(CFSTR fileName, CByteBuffer &buf)
151{
150 buf.Free(); 152 buf.Free();
153 FString path (fileName);
154 path += k_ZoneId_StreamName_With_Colon_Prefix;
151 NIO::CInFile file; 155 NIO::CInFile file;
152 if (!file.Open(fileName)) 156 if (!file.Open(path))
153 return; 157 return;
154 UInt64 fileSize; 158 UInt64 fileSize;
155 if (!file.GetLength(fileSize)) 159 if (!file.GetLength(fileSize))
156 return; 160 return;
157 if (fileSize == 0 || fileSize >= ((UInt32)1 << 16)) 161 if (fileSize == 0 || fileSize >= (1u << 15))
158 return; 162 return;
159 buf.Alloc((size_t)fileSize); 163 buf.Alloc((size_t)fileSize);
160 size_t processed; 164 size_t processed;
@@ -166,7 +170,7 @@ void ReadZoneFile_Of_BaseFile(CFSTR fileName2, CByteBuffer &buf)
166bool WriteZoneFile_To_BaseFile(CFSTR fileName, const CByteBuffer &buf) 170bool WriteZoneFile_To_BaseFile(CFSTR fileName, const CByteBuffer &buf)
167{ 171{
168 FString path (fileName); 172 FString path (fileName);
169 path += k_ZoneId_StreamName; 173 path += k_ZoneId_StreamName_With_Colon_Prefix;
170 NIO::COutFile file; 174 NIO::COutFile file;
171 if (!file.Create_ALWAYS(path)) 175 if (!file.Create_ALWAYS(path))
172 return false; 176 return false;
@@ -275,16 +279,13 @@ HRESULT CArchiveExtractCallback::PrepareHardLinks(const CRecordVector<UInt32> *r
275 279
276 280
277CArchiveExtractCallback::CArchiveExtractCallback(): 281CArchiveExtractCallback::CArchiveExtractCallback():
278 _arc(NULL), 282 // Write_CTime(true),
279 Write_CTime(true), 283 // Write_ATime(true),
280 Write_ATime(true), 284 // Write_MTime(true),
281 Write_MTime(true),
282 Is_elimPrefix_Mode(false), 285 Is_elimPrefix_Mode(false),
286 _arc(NULL),
283 _multiArchives(false) 287 _multiArchives(false)
284{ 288{
285 LocalProgressSpec = new CLocalProgress();
286 _localProgress = LocalProgressSpec;
287
288 #ifdef Z7_USE_SECURITY_CODE 289 #ifdef Z7_USE_SECURITY_CODE
289 _saclEnabled = InitLocalPrivileges(); 290 _saclEnabled = InitLocalPrivileges();
290 #endif 291 #endif
@@ -293,9 +294,9 @@ CArchiveExtractCallback::CArchiveExtractCallback():
293 294
294void CArchiveExtractCallback::InitBeforeNewArchive() 295void CArchiveExtractCallback::InitBeforeNewArchive()
295{ 296{
296 #if defined(_WIN32) && !defined(UNDER_CE) 297#if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX)
297 ZoneBuf.Free(); 298 ZoneBuf.Free();
298 #endif 299#endif
299} 300}
300 301
301void CArchiveExtractCallback::Init( 302void CArchiveExtractCallback::Init(
@@ -322,27 +323,20 @@ void CArchiveExtractCallback::Init(
322 323
323 _ntOptions = ntOptions; 324 _ntOptions = ntOptions;
324 _wildcardCensor = wildcardCensor; 325 _wildcardCensor = wildcardCensor;
325
326 _stdOutMode = stdOutMode; 326 _stdOutMode = stdOutMode;
327 _testMode = testMode; 327 _testMode = testMode;
328
329 // _progressTotal = 0;
330 // _progressTotal_Defined = false;
331
332 _packTotal = packSize; 328 _packTotal = packSize;
333 _progressTotal = packSize; 329 _progressTotal = packSize;
334 _progressTotal_Defined = true; 330 // _progressTotal = 0;
335 331 // _progressTotal_Defined = false;
332 // _progressTotal_Defined = true;
336 _extractCallback2 = extractCallback2; 333 _extractCallback2 = extractCallback2;
337
338 /* 334 /*
339 _compressProgress.Release(); 335 _compressProgress.Release();
340 _extractCallback2.QueryInterface(IID_ICompressProgressInfo, &_compressProgress); 336 _extractCallback2.QueryInterface(IID_ICompressProgressInfo, &_compressProgress);
341
342 _callbackMessage.Release(); 337 _callbackMessage.Release();
343 _extractCallback2.QueryInterface(IID_IArchiveExtractCallbackMessage2, &_callbackMessage); 338 _extractCallback2.QueryInterface(IID_IArchiveExtractCallbackMessage2, &_callbackMessage);
344 */ 339 */
345
346 _folderArchiveExtractCallback2.Release(); 340 _folderArchiveExtractCallback2.Release();
347 _extractCallback2.QueryInterface(IID_IFolderArchiveExtractCallback2, &_folderArchiveExtractCallback2); 341 _extractCallback2.QueryInterface(IID_IFolderArchiveExtractCallback2, &_folderArchiveExtractCallback2);
348 342
@@ -390,7 +384,7 @@ Z7_COM7F_IMF(CArchiveExtractCallback::SetTotal(UInt64 size))
390{ 384{
391 COM_TRY_BEGIN 385 COM_TRY_BEGIN
392 _progressTotal = size; 386 _progressTotal = size;
393 _progressTotal_Defined = true; 387 // _progressTotal_Defined = true;
394 if (!_multiArchives && _extractCallback2) 388 if (!_multiArchives && _extractCallback2)
395 return _extractCallback2->SetTotal(size); 389 return _extractCallback2->SetTotal(size);
396 return S_OK; 390 return S_OK;
@@ -430,7 +424,7 @@ Z7_COM7F_IMF(CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue))
430 if (_multiArchives) 424 if (_multiArchives)
431 { 425 {
432 packCur = LocalProgressSpec->InSize; 426 packCur = LocalProgressSpec->InSize;
433 if (completeValue && _progressTotal_Defined) 427 if (completeValue /* && _progressTotal_Defined */)
434 packCur += MyMultDiv64(*completeValue, _progressTotal, _packTotal); 428 packCur += MyMultDiv64(*completeValue, _progressTotal, _packTotal);
435 completeValue = &packCur; 429 completeValue = &packCur;
436 } 430 }
@@ -443,7 +437,7 @@ Z7_COM7F_IMF(CArchiveExtractCallback::SetCompleted(const UInt64 *completeValue))
443Z7_COM7F_IMF(CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)) 437Z7_COM7F_IMF(CArchiveExtractCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize))
444{ 438{
445 COM_TRY_BEGIN 439 COM_TRY_BEGIN
446 return _localProgress->SetRatioInfo(inSize, outSize); 440 return LocalProgressSpec.Interface()->SetRatioInfo(inSize, outSize);
447 COM_TRY_END 441 COM_TRY_END
448} 442}
449 443
@@ -582,13 +576,23 @@ HRESULT CArchiveExtractCallback::SendMessageError2(HRESULT errorCode, const char
582 576
583#ifndef Z7_SFX 577#ifndef Z7_SFX
584 578
579Z7_CLASS_IMP_COM_1(
580 CGetProp
581 , IGetProp
582)
583public:
584 UInt32 IndexInArc;
585 const CArc *Arc;
586 // UString BaseName; // relative path
587};
588
585Z7_COM7F_IMF(CGetProp::GetProp(PROPID propID, PROPVARIANT *value)) 589Z7_COM7F_IMF(CGetProp::GetProp(PROPID propID, PROPVARIANT *value))
586{ 590{
587 /* 591 /*
588 if (propID == kpidName) 592 if (propID == kpidBaseName)
589 { 593 {
590 COM_TRY_BEGIN 594 COM_TRY_BEGIN
591 NCOM::CPropVariant prop = Name; 595 NCOM::CPropVariant prop = BaseName;
592 prop.Detach(value); 596 prop.Detach(value);
593 return S_OK; 597 return S_OK;
594 COM_TRY_END 598 COM_TRY_END
@@ -1087,7 +1091,7 @@ void CArchiveExtractCallback::GetFiTimesCAM(CFiTimesCAM &pt)
1087 pt.ATime_Defined = false; 1091 pt.ATime_Defined = false;
1088 pt.MTime_Defined = false; 1092 pt.MTime_Defined = false;
1089 1093
1090 if (Write_MTime) 1094 // if (Write_MTime)
1091 { 1095 {
1092 if (_fi.MTime.Def) 1096 if (_fi.MTime.Def)
1093 { 1097 {
@@ -1101,13 +1105,13 @@ void CArchiveExtractCallback::GetFiTimesCAM(CFiTimesCAM &pt)
1101 } 1105 }
1102 } 1106 }
1103 1107
1104 if (Write_CTime && _fi.CTime.Def) 1108 if (/* Write_CTime && */ _fi.CTime.Def)
1105 { 1109 {
1106 _fi.CTime.Write_To_FiTime(pt.CTime); 1110 _fi.CTime.Write_To_FiTime(pt.CTime);
1107 pt.CTime_Defined = true; 1111 pt.CTime_Defined = true;
1108 } 1112 }
1109 1113
1110 if (Write_ATime && _fi.ATime.Def) 1114 if (/* Write_ATime && */ _fi.ATime.Def)
1111 { 1115 {
1112 _fi.ATime.Write_To_FiTime(pt.ATime); 1116 _fi.ATime.Write_To_FiTime(pt.ATime);
1113 pt.ATime_Defined = true; 1117 pt.ATime_Defined = true;
@@ -1302,7 +1306,7 @@ HRESULT CArchiveExtractCallback::CheckExistFile(FString &fullProcessedPath, bool
1302 { 1306 {
1303 #if defined(_WIN32) && !defined(UNDER_CE) 1307 #if defined(_WIN32) && !defined(UNDER_CE)
1304 // we need to clear READ-ONLY of parent before creating alt stream 1308 // we need to clear READ-ONLY of parent before creating alt stream
1305 int colonPos = NName::FindAltStreamColon(fullProcessedPath); 1309 const int colonPos = NName::FindAltStreamColon(fullProcessedPath);
1306 if (colonPos >= 0 && fullProcessedPath[(unsigned)colonPos + 1] != 0) 1310 if (colonPos >= 0 && fullProcessedPath[(unsigned)colonPos + 1] != 0)
1307 { 1311 {
1308 FString parentFsPath (fullProcessedPath); 1312 FString parentFsPath (fullProcessedPath);
@@ -1311,7 +1315,11 @@ HRESULT CArchiveExtractCallback::CheckExistFile(FString &fullProcessedPath, bool
1311 if (parentFi.Find(parentFsPath)) 1315 if (parentFi.Find(parentFsPath))
1312 { 1316 {
1313 if (parentFi.IsReadOnly()) 1317 if (parentFi.IsReadOnly())
1318 {
1319 _altStream_NeedRestore_Attrib_for_parentFsPath = parentFsPath;
1320 _altStream_NeedRestore_AttribVal = parentFi.Attrib;
1314 SetFileAttrib(parentFsPath, parentFi.Attrib & ~(DWORD)FILE_ATTRIBUTE_READONLY); 1321 SetFileAttrib(parentFsPath, parentFi.Attrib & ~(DWORD)FILE_ATTRIBUTE_READONLY);
1322 }
1315 } 1323 }
1316 } 1324 }
1317 #endif // defined(_WIN32) && !defined(UNDER_CE) 1325 #endif // defined(_WIN32) && !defined(UNDER_CE)
@@ -1607,37 +1615,37 @@ Z7_COM7F_IMF(CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
1607 _bufPtrSeqOutStream.Release(); 1615 _bufPtrSeqOutStream.Release();
1608 1616
1609 _encrypted = false; 1617 _encrypted = false;
1610 _position = 0;
1611 _isSplit = false; 1618 _isSplit = false;
1612
1613 _curSize = 0;
1614 _curSize_Defined = false; 1619 _curSize_Defined = false;
1615 _fileLength_WasSet = false; 1620 _fileLength_WasSet = false;
1616 _fileLength_that_WasSet = 0;
1617 _index = index;
1618
1619 _diskFilePath.Empty();
1620
1621 _isRenamed = false; 1621 _isRenamed = false;
1622
1623 // _fi.Clear(); 1622 // _fi.Clear();
1624 1623 _extractMode = false;
1625 // _is_SymLink_in_Data = false; 1624 // _is_SymLink_in_Data = false;
1626 _is_SymLink_in_Data_Linux = false; 1625 _is_SymLink_in_Data_Linux = false;
1627
1628 _needSetAttrib = false; 1626 _needSetAttrib = false;
1629 _isSymLinkCreated = false; 1627 _isSymLinkCreated = false;
1630 _itemFailure = false; 1628 _itemFailure = false;
1631
1632 _some_pathParts_wereRemoved = false; 1629 _some_pathParts_wereRemoved = false;
1633 // _op_WasReported = false; 1630 // _op_WasReported = false;
1634 1631
1632 _position = 0;
1633 _curSize = 0;
1634 _fileLength_that_WasSet = 0;
1635 _index = index;
1636
1637#if defined(_WIN32) && !defined(UNDER_CE)
1638 _altStream_NeedRestore_AttribVal = 0;
1639 _altStream_NeedRestore_Attrib_for_parentFsPath.Empty();
1640#endif
1641
1642 _diskFilePath.Empty();
1643
1635 #ifdef SUPPORT_LINKS 1644 #ifdef SUPPORT_LINKS
1636 // _copyFile_Path.Empty(); 1645 // _copyFile_Path.Empty();
1637 _link.Clear(); 1646 _link.Clear();
1638 #endif 1647 #endif
1639 1648
1640 _extractMode = false;
1641 1649
1642 switch (askExtractMode) 1650 switch (askExtractMode)
1643 { 1651 {
@@ -1692,6 +1700,19 @@ Z7_COM7F_IMF(CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
1692 return S_OK; 1700 return S_OK;
1693 } 1701 }
1694 1702
1703#if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX)
1704 if (askExtractMode == NArchive::NExtract::NAskMode::kExtract
1705 && !_testMode
1706 && _item.IsAltStream
1707 && ZoneBuf.Size() != 0
1708 && Is_ZoneId_StreamName(_item.AltStreamName))
1709 if (ZoneMode != NExtract::NZoneIdMode::kOffice
1710 || _item.PathParts.IsEmpty()
1711 || FindExt2(kOfficeExtensions, _item.PathParts.Back()))
1712 return S_OK;
1713#endif
1714
1715
1695 #ifndef Z7_SFX 1716 #ifndef Z7_SFX
1696 if (_use_baseParentFolder_mode) 1717 if (_use_baseParentFolder_mode)
1697 { 1718 {
@@ -1810,15 +1831,11 @@ Z7_COM7F_IMF(CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
1810 1831
1811 if (ExtractToStreamCallback) 1832 if (ExtractToStreamCallback)
1812 { 1833 {
1813 if (!GetProp) 1834 CMyComPtr2_Create<IGetProp, CGetProp> GetProp;
1814 { 1835 GetProp->Arc = _arc;
1815 GetProp_Spec = new CGetProp; 1836 GetProp->IndexInArc = index;
1816 GetProp = GetProp_Spec;
1817 }
1818 GetProp_Spec->Arc = _arc;
1819 GetProp_Spec->IndexInArc = index;
1820 UString name (MakePathFromParts(pathParts)); 1837 UString name (MakePathFromParts(pathParts));
1821 1838 // GetProp->BaseName = name;
1822 #ifdef SUPPORT_ALT_STREAMS 1839 #ifdef SUPPORT_ALT_STREAMS
1823 if (_item.IsAltStream) 1840 if (_item.IsAltStream)
1824 { 1841 {
@@ -1984,6 +2001,15 @@ HRESULT CArchiveExtractCallback::CloseFile()
1984 2001
1985 RINOK(_outFileStreamSpec->Close()) 2002 RINOK(_outFileStreamSpec->Close())
1986 _outFileStream.Release(); 2003 _outFileStream.Release();
2004
2005#if defined(_WIN32) && !defined(UNDER_CE)
2006 if (!_altStream_NeedRestore_Attrib_for_parentFsPath.IsEmpty())
2007 {
2008 SetFileAttrib(_altStream_NeedRestore_Attrib_for_parentFsPath, _altStream_NeedRestore_AttribVal);
2009 _altStream_NeedRestore_Attrib_for_parentFsPath.Empty();
2010 }
2011#endif
2012
1987 return hres; 2013 return hres;
1988} 2014}
1989 2015
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.h b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
index 7eb2f67..f3ee01c 100644
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.h
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
@@ -90,25 +90,10 @@ struct CExtractNtOptions
90 } 90 }
91}; 91};
92 92
93#ifndef Z7_SFX
94
95Z7_CLASS_IMP_COM_1(
96 CGetProp
97 , IGetProp
98)
99public:
100 UInt32 IndexInArc;
101 const CArc *Arc;
102 // UString Name; // relative path
103};
104
105#endif
106 93
107#ifndef Z7_SFX 94#ifndef Z7_SFX
108#ifndef UNDER_CE 95#ifndef UNDER_CE
109
110#define SUPPORT_LINKS 96#define SUPPORT_LINKS
111
112#endif 97#endif
113#endif 98#endif
114 99
@@ -282,46 +267,44 @@ class CArchiveExtractCallback Z7_final:
282 Z7_IFACE_COM7_IMP(IArchiveRequestMemoryUseCallback) 267 Z7_IFACE_COM7_IMP(IArchiveRequestMemoryUseCallback)
283#endif 268#endif
284 269
270 // bool Write_CTime;
271 // bool Write_ATime;
272 // bool Write_MTime;
273 bool _stdOutMode;
274 bool _testMode;
275 bool _removePartsForAltStreams;
276public:
277 bool Is_elimPrefix_Mode;
278private:
279
285 const CArc *_arc; 280 const CArc *_arc;
286 CExtractNtOptions _ntOptions; 281 CExtractNtOptions _ntOptions;
287 282
283 bool _encrypted;
288 bool _isSplit; 284 bool _isSplit;
285 bool _curSize_Defined;
286 bool _fileLength_WasSet;
289 287
288 bool _isRenamed;
290 bool _extractMode; 289 bool _extractMode;
291
292 bool Write_CTime;
293 bool Write_ATime;
294 bool Write_MTime;
295 bool _keepAndReplaceEmptyDirPrefixes; // replace them to "_";
296
297 bool _encrypted;
298
299 // bool _is_SymLink_in_Data; 290 // bool _is_SymLink_in_Data;
300 bool _is_SymLink_in_Data_Linux; // false = WIN32, true = LINUX 291 bool _is_SymLink_in_Data_Linux; // false = WIN32, true = LINUX
301
302 bool _needSetAttrib; 292 bool _needSetAttrib;
303 bool _isSymLinkCreated; 293 bool _isSymLinkCreated;
304 bool _itemFailure; 294 bool _itemFailure;
305
306 bool _some_pathParts_wereRemoved; 295 bool _some_pathParts_wereRemoved;
307public:
308 bool Is_elimPrefix_Mode;
309
310private:
311 bool _curSize_Defined;
312 bool _fileLength_WasSet;
313
314 bool _removePartsForAltStreams;
315 296
316 bool _stdOutMode;
317 bool _testMode;
318 bool _multiArchives; 297 bool _multiArchives;
298 bool _keepAndReplaceEmptyDirPrefixes; // replace them to "_";
299#if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX)
300 bool _saclEnabled;
301#endif
319 302
320 NExtract::NPathMode::EEnum _pathMode; 303 NExtract::NPathMode::EEnum _pathMode;
321 NExtract::NOverwriteMode::EEnum _overwriteMode; 304 NExtract::NOverwriteMode::EEnum _overwriteMode;
322 305
323 const NWildcard::CCensorNode *_wildcardCensor; // we need wildcard for single pass mode (stdin)
324 CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2; 306 CMyComPtr<IFolderArchiveExtractCallback> _extractCallback2;
307 const NWildcard::CCensorNode *_wildcardCensor; // we need wildcard for single pass mode (stdin)
325 // CMyComPtr<ICompressProgressInfo> _compressProgress; 308 // CMyComPtr<ICompressProgressInfo> _compressProgress;
326 // CMyComPtr<IArchiveExtractCallbackMessage2> _callbackMessage; 309 // CMyComPtr<IArchiveExtractCallbackMessage2> _callbackMessage;
327 CMyComPtr<IFolderArchiveExtractCallback2> _folderArchiveExtractCallback2; 310 CMyComPtr<IFolderArchiveExtractCallback2> _folderArchiveExtractCallback2;
@@ -333,15 +316,12 @@ private:
333 #ifndef Z7_SFX 316 #ifndef Z7_SFX
334 317
335 CMyComPtr<IFolderExtractToStreamCallback> ExtractToStreamCallback; 318 CMyComPtr<IFolderExtractToStreamCallback> ExtractToStreamCallback;
336 CGetProp *GetProp_Spec;
337 CMyComPtr<IGetProp> GetProp;
338 CMyComPtr<IArchiveRequestMemoryUseCallback> _requestMemoryUseCallback; 319 CMyComPtr<IArchiveRequestMemoryUseCallback> _requestMemoryUseCallback;
339 320
340 #endif 321 #endif
341 322
342 CReadArcItem _item; 323 CReadArcItem _item;
343 FString _diskFilePath; 324 FString _diskFilePath;
344 UInt64 _position;
345 325
346 struct CProcessedFileInfo 326 struct CProcessedFileInfo
347 { 327 {
@@ -387,9 +367,17 @@ private:
387 } 367 }
388 } _fi; 368 } _fi;
389 369
390 UInt32 _index; 370 UInt64 _position;
391 UInt64 _curSize; 371 UInt64 _curSize;
392 UInt64 _fileLength_that_WasSet; 372 UInt64 _fileLength_that_WasSet;
373 UInt32 _index;
374
375// #ifdef SUPPORT_ALT_STREAMS
376#if defined(_WIN32) && !defined(UNDER_CE)
377 DWORD _altStream_NeedRestore_AttribVal;
378 FString _altStream_NeedRestore_Attrib_for_parentFsPath;
379#endif
380// #endif
393 381
394 COutFileStream *_outFileStreamSpec; 382 COutFileStream *_outFileStreamSpec;
395 CMyComPtr<ISequentialOutStream> _outFileStream; 383 CMyComPtr<ISequentialOutStream> _outFileStream;
@@ -398,9 +386,7 @@ private:
398 CBufPtrSeqOutStream *_bufPtrSeqOutStream_Spec; 386 CBufPtrSeqOutStream *_bufPtrSeqOutStream_Spec;
399 CMyComPtr<ISequentialOutStream> _bufPtrSeqOutStream; 387 CMyComPtr<ISequentialOutStream> _bufPtrSeqOutStream;
400 388
401
402 #ifndef Z7_SFX 389 #ifndef Z7_SFX
403
404 COutStreamWithHash *_hashStreamSpec; 390 COutStreamWithHash *_hashStreamSpec;
405 CMyComPtr<ISequentialOutStream> _hashStream; 391 CMyComPtr<ISequentialOutStream> _hashStream;
406 bool _hashStreamWasUsed; 392 bool _hashStreamWasUsed;
@@ -411,11 +397,9 @@ private:
411 397
412 UStringVector _removePathParts; 398 UStringVector _removePathParts;
413 399
414 CMyComPtr<ICompressProgressInfo> _localProgress;
415 UInt64 _packTotal; 400 UInt64 _packTotal;
416
417 UInt64 _progressTotal; 401 UInt64 _progressTotal;
418 bool _progressTotal_Defined; 402 // bool _progressTotal_Defined;
419 403
420 CObjectVector<CDirPathTime> _extractedFolders; 404 CObjectVector<CDirPathTime> _extractedFolders;
421 405
@@ -423,10 +407,6 @@ private:
423 // CObjectVector<NWindows::NFile::NDir::CDelayedSymLink> _delayedSymLinks; 407 // CObjectVector<NWindows::NFile::NDir::CDelayedSymLink> _delayedSymLinks;
424 #endif 408 #endif
425 409
426 #if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX)
427 bool _saclEnabled;
428 #endif
429
430 void CreateComplexDirectory(const UStringVector &dirPathParts, FString &fullPath); 410 void CreateComplexDirectory(const UStringVector &dirPathParts, FString &fullPath);
431 HRESULT GetTime(UInt32 index, PROPID propID, CArcTime &ft); 411 HRESULT GetTime(UInt32 index, PROPID propID, CArcTime &ft);
432 HRESULT GetUnpackSize(); 412 HRESULT GetUnpackSize();
@@ -441,13 +421,12 @@ public:
441 HRESULT SendMessageError_with_LastError(const char *message, const FString &path); 421 HRESULT SendMessageError_with_LastError(const char *message, const FString &path);
442 HRESULT SendMessageError2(HRESULT errorCode, const char *message, const FString &path1, const FString &path2); 422 HRESULT SendMessageError2(HRESULT errorCode, const char *message, const FString &path1, const FString &path2);
443 423
444public: 424#if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX)
445 #if defined(_WIN32) && !defined(UNDER_CE)
446 NExtract::NZoneIdMode::EEnum ZoneMode; 425 NExtract::NZoneIdMode::EEnum ZoneMode;
447 CByteBuffer ZoneBuf; 426 CByteBuffer ZoneBuf;
448 #endif 427#endif
449 428
450 CLocalProgress *LocalProgressSpec; 429 CMyComPtr2_Create<ICompressProgressInfo, CLocalProgress> LocalProgressSpec;
451 430
452 UInt64 NumFolders; 431 UInt64 NumFolders;
453 UInt64 NumFiles; 432 UInt64 NumFiles;
@@ -468,11 +447,11 @@ public:
468 _multiArchives = multiArchives; 447 _multiArchives = multiArchives;
469 _pathMode = pathMode; 448 _pathMode = pathMode;
470 _overwriteMode = overwriteMode; 449 _overwriteMode = overwriteMode;
471 #if defined(_WIN32) && !defined(UNDER_CE) 450#if defined(_WIN32) && !defined(UNDER_CE) && !defined(Z7_SFX)
472 ZoneMode = zoneMode; 451 ZoneMode = zoneMode;
473 #else 452#else
474 UNUSED_VAR(zoneMode) 453 UNUSED_VAR(zoneMode)
475 #endif 454#endif
476 _keepAndReplaceEmptyDirPrefixes = keepAndReplaceEmptyDirPrefixes; 455 _keepAndReplaceEmptyDirPrefixes = keepAndReplaceEmptyDirPrefixes;
477 NumFolders = NumFiles = NumAltStreams = UnpackSize = AltStreams_UnpackSize = 0; 456 NumFolders = NumFiles = NumAltStreams = UnpackSize = AltStreams_UnpackSize = 0;
478 } 457 }
@@ -551,7 +530,6 @@ private:
551 void GetFiTimesCAM(CFiTimesCAM &pt); 530 void GetFiTimesCAM(CFiTimesCAM &pt);
552 void CreateFolders(); 531 void CreateFolders();
553 532
554 bool _isRenamed;
555 HRESULT CheckExistFile(FString &fullProcessedPath, bool &needExit); 533 HRESULT CheckExistFile(FString &fullProcessedPath, bool &needExit);
556 HRESULT GetExtractStream(CMyComPtr<ISequentialOutStream> &outStreamLoc, bool &needExit); 534 HRESULT GetExtractStream(CMyComPtr<ISequentialOutStream> &outStreamLoc, bool &needExit);
557 HRESULT GetItem(UInt32 index); 535 HRESULT GetItem(UInt32 index);
@@ -599,7 +577,8 @@ struct CArchiveExtractCallback_Closer
599 577
600bool CensorNode_CheckPath(const NWildcard::CCensorNode &node, const CReadArcItem &item); 578bool CensorNode_CheckPath(const NWildcard::CCensorNode &node, const CReadArcItem &item);
601 579
602void ReadZoneFile_Of_BaseFile(CFSTR fileName2, CByteBuffer &buf); 580bool Is_ZoneId_StreamName(const wchar_t *s);
581void ReadZoneFile_Of_BaseFile(CFSTR fileName, CByteBuffer &buf);
603bool WriteZoneFile_To_BaseFile(CFSTR fileName, const CByteBuffer &buf); 582bool WriteZoneFile_To_BaseFile(CFSTR fileName, const CByteBuffer &buf);
604 583
605#endif 584#endif
diff --git a/CPP/7zip/UI/Common/Bench.cpp b/CPP/7zip/UI/Common/Bench.cpp
index e1ca846..05d66aa 100644
--- a/CPP/7zip/UI/Common/Bench.cpp
+++ b/CPP/7zip/UI/Common/Bench.cpp
@@ -2298,6 +2298,28 @@ HRESULT CCrcInfo_Base::Generate(const Byte *data, size_t size)
2298} 2298}
2299 2299
2300 2300
2301#if 1
2302#define HashUpdate(hf, data, size) hf->Update(data, size)
2303#else
2304// for debug:
2305static void HashUpdate(IHasher *hf, const void *data, UInt32 size)
2306{
2307 for (;;)
2308 {
2309 if (size == 0)
2310 return;
2311 UInt32 size2 = (size * 0x85EBCA87) % size / 8;
2312 // UInt32 size2 = size / 2;
2313 if (size2 == 0)
2314 size2 = 1;
2315 hf->Update(data, size2);
2316 data = (const void *)((const Byte *)data + size2);
2317 size -= size2;
2318 }
2319}
2320#endif
2321
2322
2301HRESULT CCrcInfo_Base::CrcProcess(UInt64 numIterations, 2323HRESULT CCrcInfo_Base::CrcProcess(UInt64 numIterations,
2302 const UInt32 *checkSum, IHasher *hf, 2324 const UInt32 *checkSum, IHasher *hf,
2303 IBenchPrintCallback *callback) 2325 IBenchPrintCallback *callback)
@@ -2328,7 +2350,7 @@ HRESULT CCrcInfo_Base::CrcProcess(UInt64 numIterations,
2328 const size_t rem = size - pos; 2350 const size_t rem = size - pos;
2329 const UInt32 kStep = ((UInt32)1 << 31); 2351 const UInt32 kStep = ((UInt32)1 << 31);
2330 const UInt32 curSize = (rem < kStep) ? (UInt32)rem : kStep; 2352 const UInt32 curSize = (rem < kStep) ? (UInt32)rem : kStep;
2331 hf->Update(buf + pos, curSize); 2353 HashUpdate(hf, buf + pos, curSize);
2332 pos += curSize; 2354 pos += curSize;
2333 } 2355 }
2334 while (pos != size); 2356 while (pos != size);
@@ -2742,14 +2764,20 @@ static const CBenchHash g_Hash[] =
2742 { 2, 128 *ARM_CRC_MUL, 0x21e207bb, "CRC32:32" }, 2764 { 2, 128 *ARM_CRC_MUL, 0x21e207bb, "CRC32:32" },
2743 { 2, 64 *ARM_CRC_MUL, 0x21e207bb, "CRC32:64" }, 2765 { 2, 64 *ARM_CRC_MUL, 0x21e207bb, "CRC32:64" },
2744 { 10, 256, 0x41b901d1, "CRC64" }, 2766 { 10, 256, 0x41b901d1, "CRC64" },
2745 { 10, 64, 0x43eac94f, "XXH64" }, 2767 { 5, 64, 0x43eac94f, "XXH64" },
2746 2768 { 2, 2340, 0x3398a904, "MD5" },
2747 { 10, 5100, 0x7913ba03, "SHA256:1" }, 2769 { 10, 2340, 0xff769021, "SHA1:1" },
2748 { 2, CMPLX((32 * 4 + 1) * 4 + 4), 0x7913ba03, "SHA256:2" },
2749
2750 { 10, 2340, 0xff769021, "SHA1:1" },
2751 { 2, CMPLX((20 * 6 + 1) * 4 + 4), 0xff769021, "SHA1:2" }, 2770 { 2, CMPLX((20 * 6 + 1) * 4 + 4), 0xff769021, "SHA1:2" },
2752 2771 { 10, 5100, 0x7913ba03, "SHA256:1" },
2772 { 2, CMPLX((32 * 4 + 1) * 4 + 4), 0x7913ba03, "SHA256:2" },
2773 { 5, 3200, 0xe7aeb394, "SHA512:1" },
2774 { 2, CMPLX((40 * 4 + 1) * 4 + 4), 0xe7aeb394, "SHA512:2" },
2775 // { 10, 3428, 0x1cc99b18, "SHAKE128" },
2776 // { 10, 4235, 0x74eaddc3, "SHAKE256" },
2777 // { 10, 4000, 0xdf3e6863, "SHA3-224" },
2778 { 5, 4200, 0xcecac10d, "SHA3-256" },
2779 // { 10, 5538, 0x4e5d9163, "SHA3-384" },
2780 // { 10, 8000, 0x96a58289, "SHA3-512" },
2753 { 2, 4096, 0x85189d02, "BLAKE2sp:1" }, 2781 { 2, 4096, 0x85189d02, "BLAKE2sp:1" },
2754 { 2, 1024, 0x85189d02, "BLAKE2sp:2" }, // sse2-way4-fast 2782 { 2, 1024, 0x85189d02, "BLAKE2sp:2" }, // sse2-way4-fast
2755 { 2, 512, 0x85189d02, "BLAKE2sp:3" } // avx2-way8-fast 2783 { 2, 512, 0x85189d02, "BLAKE2sp:3" } // avx2-way8-fast
@@ -3687,7 +3715,7 @@ HRESULT Bench(
3687 return E_FAIL; 3715 return E_FAIL;
3688 3716
3689 UInt32 numCPUs = 1; 3717 UInt32 numCPUs = 1;
3690 UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29; 3718 size_t ramSize = (size_t)sizeof(size_t) << 29;
3691 3719
3692 NSystem::CProcessAffinity threadsInfo; 3720 NSystem::CProcessAffinity threadsInfo;
3693 threadsInfo.InitST(); 3721 threadsInfo.InitST();
@@ -4580,6 +4608,8 @@ HRESULT Bench(
4580 4608
4581 if (!dictIsDefined && !onlyHashBench) 4609 if (!dictIsDefined && !onlyHashBench)
4582 { 4610 {
4611 // we use dicSizeLog and dicSizeLog_Main for data size.
4612 // also we use it to reduce dictionary size of LZMA encoder via NCoderPropID::kReduceSize.
4583 const unsigned dicSizeLog_Main = (totalBenchMode ? 24 : 25); 4613 const unsigned dicSizeLog_Main = (totalBenchMode ? 24 : 25);
4584 unsigned dicSizeLog = dicSizeLog_Main; 4614 unsigned dicSizeLog = dicSizeLog_Main;
4585 4615
diff --git a/CPP/7zip/UI/Common/EnumDirItems.cpp b/CPP/7zip/UI/Common/EnumDirItems.cpp
index 0758547..11643ae 100644
--- a/CPP/7zip/UI/Common/EnumDirItems.cpp
+++ b/CPP/7zip/UI/Common/EnumDirItems.cpp
@@ -671,7 +671,7 @@ static HRESULT EnumerateForItem(
671 } 671 }
672 672
673 #if defined(_WIN32) 673 #if defined(_WIN32)
674 if (needAltStreams && dirItems.ScanAltStreams) 674 if (needAltStreams && dirItems.ScanAltStreams && !fi.IsAltStream)
675 { 675 {
676 RINOK(EnumerateAltStreams(fi, curNode, phyParent, logParent, 676 RINOK(EnumerateAltStreams(fi, curNode, phyParent, logParent,
677 phyPrefix + fi.Name, // with (fi.Name) 677 phyPrefix + fi.Name, // with (fi.Name)
@@ -929,7 +929,7 @@ static HRESULT EnumerateDirItems(
929 } 929 }
930 930
931 #if defined(_WIN32) 931 #if defined(_WIN32)
932 if (needAltStreams && dirItems.ScanAltStreams) 932 if (needAltStreams && dirItems.ScanAltStreams && !fi.IsAltStream)
933 { 933 {
934 UStringVector pathParts; 934 UStringVector pathParts;
935 pathParts.Add(fs2us(fi.Name)); 935 pathParts.Add(fs2us(fi.Name));
diff --git a/CPP/7zip/UI/Common/HashCalc.cpp b/CPP/7zip/UI/Common/HashCalc.cpp
index f3d65ef..9caac36 100644
--- a/CPP/7zip/UI/Common/HashCalc.cpp
+++ b/CPP/7zip/UI/Common/HashCalc.cpp
@@ -773,13 +773,21 @@ static const char * const k_CsumMethodNames[] =
773{ 773{
774 "sha256" 774 "sha256"
775 , "sha224" 775 , "sha224"
776// , "sha512/224" 776// , "sha512-224"
777// , "sha512/256" 777// , "sha512-256"
778 , "sha512"
779 , "sha384" 778 , "sha384"
779 , "sha512"
780// , "sha3-224"
781 , "sha3-256"
782// , "sha3-384"
783// , "sha3-512"
784// , "shake128"
785// , "shake256"
780 , "sha1" 786 , "sha1"
781 , "md5" 787 , "md5"
788 , "blake2sp"
782 , "blake2b" 789 , "blake2b"
790 , "xxh64"
783 , "crc64" 791 , "crc64"
784 , "crc32" 792 , "crc32"
785 , "cksum" 793 , "cksum"
@@ -2076,11 +2084,27 @@ void Codecs_AddHashArcHandler(CCodecs *codecs)
2076 2084
2077 // ubuntu uses "SHA256SUMS" file 2085 // ubuntu uses "SHA256SUMS" file
2078 item.AddExts(UString ( 2086 item.AddExts(UString (
2079 "sha256 sha512 sha224 sha384 sha1 sha md5" 2087 "sha256"
2080 // "b2sum" 2088 " sha512"
2089 " sha384"
2090 " sha224"
2091 // " sha512-224"
2092 // " sha512-256"
2093 // " sha3-224"
2094 " sha3-256"
2095 // " sha3-384"
2096 // " sha3-512"
2097 // " shake128"
2098 // " shake256"
2099 " sha1"
2100 " sha"
2101 " md5"
2102 " blake2sp"
2103 " xxh64"
2081 " crc32 crc64" 2104 " crc32 crc64"
2082 " asc" 2105 " asc"
2083 " cksum" 2106 " cksum"
2107 // " b2sum"
2084 ), 2108 ),
2085 UString()); 2109 UString());
2086 2110
diff --git a/CPP/7zip/UI/Common/TempFiles.cpp b/CPP/7zip/UI/Common/TempFiles.cpp
index 2f86838..ad16e36 100644
--- a/CPP/7zip/UI/Common/TempFiles.cpp
+++ b/CPP/7zip/UI/Common/TempFiles.cpp
@@ -13,7 +13,8 @@ void CTempFiles::Clear()
13{ 13{
14 while (!Paths.IsEmpty()) 14 while (!Paths.IsEmpty())
15 { 15 {
16 NDir::DeleteFileAlways(Paths.Back()); 16 if (NeedDeleteFiles)
17 NDir::DeleteFileAlways(Paths.Back());
17 Paths.DeleteBack(); 18 Paths.DeleteBack();
18 } 19 }
19} 20}
diff --git a/CPP/7zip/UI/Common/TempFiles.h b/CPP/7zip/UI/Common/TempFiles.h
index dd4ac20..83c741f 100644
--- a/CPP/7zip/UI/Common/TempFiles.h
+++ b/CPP/7zip/UI/Common/TempFiles.h
@@ -10,6 +10,9 @@ class CTempFiles
10 void Clear(); 10 void Clear();
11public: 11public:
12 FStringVector Paths; 12 FStringVector Paths;
13 bool NeedDeleteFiles;
14
15 CTempFiles(): NeedDeleteFiles(true) {}
13 ~CTempFiles() { Clear(); } 16 ~CTempFiles() { Clear(); }
14}; 17};
15 18
diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp
index ed48605..b959a3c 100644
--- a/CPP/7zip/UI/Common/Update.cpp
+++ b/CPP/7zip/UI/Common/Update.cpp
@@ -1096,6 +1096,30 @@ typedef Z7_WIN_MAPISENDMAILW FAR *Z7_WIN_LPMAPISENDMAILW;
1096#endif // _WIN32 1096#endif // _WIN32
1097 1097
1098 1098
1099struct C_CopyFileProgress_to_IUpdateCallbackUI2 Z7_final:
1100 public ICopyFileProgress
1101{
1102 IUpdateCallbackUI2 *Callback;
1103 HRESULT CallbackResult;
1104 // bool Disable_Break;
1105
1106 virtual DWORD CopyFileProgress(UInt64 total, UInt64 current) Z7_override
1107 {
1108 const HRESULT res = Callback->MoveArc_Progress(total, current);
1109 CallbackResult = res;
1110 // if (Disable_Break && res == E_ABORT) res = S_OK;
1111 return res == S_OK ? PROGRESS_CONTINUE : PROGRESS_CANCEL;
1112 }
1113
1114 C_CopyFileProgress_to_IUpdateCallbackUI2(
1115 IUpdateCallbackUI2 *callback) :
1116 Callback(callback),
1117 CallbackResult(S_OK)
1118 // , Disable_Break(false)
1119 {}
1120};
1121
1122
1099HRESULT UpdateArchive( 1123HRESULT UpdateArchive(
1100 CCodecs *codecs, 1124 CCodecs *codecs,
1101 const CObjectVector<COpenType> &types, 1125 const CObjectVector<COpenType> &types,
@@ -1311,7 +1335,7 @@ HRESULT UpdateArchive(
1311 return E_NOTIMPL; 1335 return E_NOTIMPL;
1312 } 1336 }
1313 1337
1314 bool thereIsInArchive = arcLink.IsOpen; 1338 const bool thereIsInArchive = arcLink.IsOpen;
1315 if (!thereIsInArchive && renameMode) 1339 if (!thereIsInArchive && renameMode)
1316 return E_FAIL; 1340 return E_FAIL;
1317 1341
@@ -1588,7 +1612,14 @@ HRESULT UpdateArchive(
1588 multiStreams.DisableDeletion(); 1612 multiStreams.DisableDeletion();
1589 RINOK(multiStreams.Destruct()) 1613 RINOK(multiStreams.Destruct())
1590 1614
1591 tempFiles.Paths.Clear(); 1615 // here we disable deleting of temp archives.
1616 // note: archive moving can fail, or it can be interrupted,
1617 // if we move new temp update from another volume.
1618 // And we still want to keep temp archive in that case,
1619 // because we will have deleted original archive.
1620 tempFiles.NeedDeleteFiles = false;
1621 // tempFiles.Paths.Clear();
1622
1592 if (createTempFile) 1623 if (createTempFile)
1593 { 1624 {
1594 try 1625 try
@@ -1603,16 +1634,29 @@ HRESULT UpdateArchive(
1603 if (!DeleteFileAlways(us2fs(arcPath))) 1634 if (!DeleteFileAlways(us2fs(arcPath)))
1604 return errorInfo.SetFromLastError("cannot delete the file", us2fs(arcPath)); 1635 return errorInfo.SetFromLastError("cannot delete the file", us2fs(arcPath));
1605 } 1636 }
1606 1637
1607 if (!MyMoveFile(tempPath, us2fs(arcPath))) 1638 UInt64 totalArcSize = 0;
1639 {
1640 NFind::CFileInfo fi;
1641 if (fi.Find(tempPath))
1642 totalArcSize = fi.Size;
1643 }
1644 RINOK(callback->MoveArc_Start(fs2us(tempPath), arcPath,
1645 totalArcSize, BoolToInt(thereIsInArchive)))
1646
1647 C_CopyFileProgress_to_IUpdateCallbackUI2 prox(callback);
1648 // if we update archive, we have removed original archive.
1649 // So if we break archive moving, we will have only temporary archive.
1650 // We can disable breaking here:
1651 // prox.Disable_Break = thereIsInArchive;
1652
1653 if (!MyMoveFile_with_Progress(tempPath, us2fs(arcPath), &prox))
1608 { 1654 {
1609 errorInfo.SystemError = ::GetLastError(); 1655 errorInfo.SystemError = ::GetLastError();
1610 errorInfo.Message = "cannot move the file"; 1656 errorInfo.Message = "cannot move the file";
1611 if (errorInfo.SystemError == ERROR_INVALID_PARAMETER) 1657 if (errorInfo.SystemError == ERROR_INVALID_PARAMETER)
1612 { 1658 {
1613 NFind::CFileInfo fi; 1659 if (totalArcSize > (UInt32)(Int32)-1)
1614 if (fi.Find(tempPath) &&
1615 fi.Size > (UInt32)(Int32)-1)
1616 { 1660 {
1617 // bool isFsDetected = false; 1661 // bool isFsDetected = false;
1618 // if (NSystem::Is_File_LimitedBy_4GB(us2fs(arcPath), isFsDetected) || !isFsDetected) 1662 // if (NSystem::Is_File_LimitedBy_4GB(us2fs(arcPath), isFsDetected) || !isFsDetected)
@@ -1622,10 +1666,20 @@ HRESULT UpdateArchive(
1622 } 1666 }
1623 } 1667 }
1624 } 1668 }
1669 // if there was no input archive, and we have operation breaking.
1670 // then we can remove temporary archive, because we still have original uncompressed files.
1671 if (!thereIsInArchive
1672 && prox.CallbackResult == E_ABORT)
1673 tempFiles.NeedDeleteFiles = true;
1625 errorInfo.FileNames.Add(tempPath); 1674 errorInfo.FileNames.Add(tempPath);
1626 errorInfo.FileNames.Add(us2fs(arcPath)); 1675 errorInfo.FileNames.Add(us2fs(arcPath));
1676 RINOK(prox.CallbackResult)
1627 return errorInfo.Get_HRESULT_Error(); 1677 return errorInfo.Get_HRESULT_Error();
1628 } 1678 }
1679
1680 // MoveArc_Finish() can return delayed user break (E_ABORT) status,
1681 // if callback callee ignored interruption to finish archive creation operation.
1682 RINOK(callback->MoveArc_Finish())
1629 1683
1630 /* 1684 /*
1631 if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_READONLY)) 1685 if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_READONLY))
diff --git a/CPP/7zip/UI/Common/Update.h b/CPP/7zip/UI/Common/Update.h
index a9459ff..216339a 100644
--- a/CPP/7zip/UI/Common/Update.h
+++ b/CPP/7zip/UI/Common/Update.h
@@ -12,8 +12,6 @@
12#include "UpdateAction.h" 12#include "UpdateAction.h"
13#include "UpdateCallback.h" 13#include "UpdateCallback.h"
14 14
15#include "DirItem.h"
16
17enum EArcNameMode 15enum EArcNameMode
18{ 16{
19 k_ArcNameMode_Smart, 17 k_ArcNameMode_Smart,
@@ -195,6 +193,9 @@ Z7_PURE_INTERFACES_BEGIN
195 virtual HRESULT FinishArchive(const CFinishArchiveStat &st) x \ 193 virtual HRESULT FinishArchive(const CFinishArchiveStat &st) x \
196 virtual HRESULT DeletingAfterArchiving(const FString &path, bool isDir) x \ 194 virtual HRESULT DeletingAfterArchiving(const FString &path, bool isDir) x \
197 virtual HRESULT FinishDeletingAfterArchiving() x \ 195 virtual HRESULT FinishDeletingAfterArchiving() x \
196 virtual HRESULT MoveArc_Start(const wchar_t *srcTempPath, const wchar_t *destFinalPath, UInt64 size, Int32 updateMode) x \
197 virtual HRESULT MoveArc_Progress(UInt64 total, UInt64 current) x \
198 virtual HRESULT MoveArc_Finish() x \
198 199
199DECLARE_INTERFACE(IUpdateCallbackUI2): 200DECLARE_INTERFACE(IUpdateCallbackUI2):
200 public IUpdateCallbackUI, 201 public IUpdateCallbackUI,
diff --git a/CPP/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp
index cfec635..a492967 100644
--- a/CPP/7zip/UI/Common/WorkDir.cpp
+++ b/CPP/7zip/UI/Common/WorkDir.cpp
@@ -63,24 +63,22 @@ HRESULT CWorkDirTempFile::CreateTempFile(const FString &originalPath)
63 NWorkDir::CInfo workDirInfo; 63 NWorkDir::CInfo workDirInfo;
64 workDirInfo.Load(); 64 workDirInfo.Load();
65 FString namePart; 65 FString namePart;
66 const FString workDir = GetWorkDir(workDirInfo, originalPath, namePart); 66 FString path = GetWorkDir(workDirInfo, originalPath, namePart);
67 CreateComplexDir(workDir); 67 CreateComplexDir(path);
68 path += namePart;
68 _outStreamSpec = new COutFileStream; 69 _outStreamSpec = new COutFileStream;
69 OutStream = _outStreamSpec; 70 OutStream = _outStreamSpec;
70 if (!_tempFile.Create(workDir + namePart, &_outStreamSpec->File)) 71 if (!_tempFile.Create(path, &_outStreamSpec->File))
71 {
72 return GetLastError_noZero_HRESULT(); 72 return GetLastError_noZero_HRESULT();
73 }
74 _originalPath = originalPath; 73 _originalPath = originalPath;
75 return S_OK; 74 return S_OK;
76} 75}
77 76
78HRESULT CWorkDirTempFile::MoveToOriginal(bool deleteOriginal) 77HRESULT CWorkDirTempFile::MoveToOriginal(bool deleteOriginal,
78 NWindows::NFile::NDir::ICopyFileProgress *progress)
79{ 79{
80 OutStream.Release(); 80 OutStream.Release();
81 if (!_tempFile.MoveTo(_originalPath, deleteOriginal)) 81 if (!_tempFile.MoveTo(_originalPath, deleteOriginal, progress))
82 {
83 return GetLastError_noZero_HRESULT(); 82 return GetLastError_noZero_HRESULT();
84 }
85 return S_OK; 83 return S_OK;
86} 84}
diff --git a/CPP/7zip/UI/Common/WorkDir.h b/CPP/7zip/UI/Common/WorkDir.h
index d32ab9d..fed8c4a 100644
--- a/CPP/7zip/UI/Common/WorkDir.h
+++ b/CPP/7zip/UI/Common/WorkDir.h
@@ -11,7 +11,7 @@
11 11
12FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FString &fileName); 12FString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const FString &path, FString &fileName);
13 13
14class CWorkDirTempFile 14class CWorkDirTempFile MY_UNCOPYABLE
15{ 15{
16 FString _originalPath; 16 FString _originalPath;
17 NWindows::NFile::NDir::CTempFile _tempFile; 17 NWindows::NFile::NDir::CTempFile _tempFile;
@@ -19,8 +19,12 @@ class CWorkDirTempFile
19public: 19public:
20 CMyComPtr<IOutStream> OutStream; 20 CMyComPtr<IOutStream> OutStream;
21 21
22 const FString &Get_OriginalFilePath() const { return _originalPath; }
23 const FString &Get_TempFilePath() const { return _tempFile.GetPath(); }
24
22 HRESULT CreateTempFile(const FString &originalPath); 25 HRESULT CreateTempFile(const FString &originalPath);
23 HRESULT MoveToOriginal(bool deleteOriginal); 26 HRESULT MoveToOriginal(bool deleteOriginal,
27 NWindows::NFile::NDir::ICopyFileProgress *progress = NULL);
24}; 28};
25 29
26#endif 30#endif
diff --git a/CPP/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp
index 73c56cf..936b888 100644
--- a/CPP/7zip/UI/Common/ZipRegistry.cpp
+++ b/CPP/7zip/UI/Common/ZipRegistry.cpp
@@ -45,8 +45,8 @@ static void Key_Set_UInt32(CKey &key, LPCTSTR name, UInt32 value)
45 45
46static void Key_Get_UInt32(CKey &key, LPCTSTR name, UInt32 &value) 46static void Key_Get_UInt32(CKey &key, LPCTSTR name, UInt32 &value)
47{ 47{
48 if (key.QueryValue(name, value) != ERROR_SUCCESS) 48 value = (UInt32)(Int32)-1;
49 value = (UInt32)(Int32)-1; 49 key.GetValue_UInt32_IfOk(name, value);
50} 50}
51 51
52 52
@@ -59,7 +59,7 @@ static void Key_Set_BoolPair(CKey &key, LPCTSTR name, const CBoolPair &b)
59static void Key_Set_bool_if_Changed(CKey &key, LPCTSTR name, bool val) 59static void Key_Set_bool_if_Changed(CKey &key, LPCTSTR name, bool val)
60{ 60{
61 bool oldVal = false; 61 bool oldVal = false;
62 if (key.GetValue_IfOk(name, oldVal) == ERROR_SUCCESS) 62 if (key.GetValue_bool_IfOk(name, oldVal) == ERROR_SUCCESS)
63 if (val == oldVal) 63 if (val == oldVal)
64 return; 64 return;
65 key.SetValue(name, val); 65 key.SetValue(name, val);
@@ -76,13 +76,13 @@ static void Key_Set_BoolPair_Delete_IfNotDef(CKey &key, LPCTSTR name, const CBoo
76static void Key_Get_BoolPair(CKey &key, LPCTSTR name, CBoolPair &b) 76static void Key_Get_BoolPair(CKey &key, LPCTSTR name, CBoolPair &b)
77{ 77{
78 b.Val = false; 78 b.Val = false;
79 b.Def = (key.GetValue_IfOk(name, b.Val) == ERROR_SUCCESS); 79 b.Def = (key.GetValue_bool_IfOk(name, b.Val) == ERROR_SUCCESS);
80} 80}
81 81
82static void Key_Get_BoolPair_true(CKey &key, LPCTSTR name, CBoolPair &b) 82static void Key_Get_BoolPair_true(CKey &key, LPCTSTR name, CBoolPair &b)
83{ 83{
84 b.Val = true; 84 b.Val = true;
85 b.Def = (key.GetValue_IfOk(name, b.Val) == ERROR_SUCCESS); 85 b.Def = (key.GetValue_bool_IfOk(name, b.Val) == ERROR_SUCCESS);
86} 86}
87 87
88namespace NExtract 88namespace NExtract
@@ -155,12 +155,12 @@ void CInfo::Load()
155 155
156 key.GetValue_Strings(kPathHistory, Paths); 156 key.GetValue_Strings(kPathHistory, Paths);
157 UInt32 v; 157 UInt32 v;
158 if (key.QueryValue(kExtractMode, v) == ERROR_SUCCESS && v <= NPathMode::kAbsPaths) 158 if (key.GetValue_UInt32_IfOk(kExtractMode, v) == ERROR_SUCCESS && v <= NPathMode::kAbsPaths)
159 { 159 {
160 PathMode = (NPathMode::EEnum)v; 160 PathMode = (NPathMode::EEnum)v;
161 PathMode_Force = true; 161 PathMode_Force = true;
162 } 162 }
163 if (key.QueryValue(kOverwriteMode, v) == ERROR_SUCCESS && v <= NOverwriteMode::kRenameExisting) 163 if (key.GetValue_UInt32_IfOk(kOverwriteMode, v) == ERROR_SUCCESS && v <= NOverwriteMode::kRenameExisting)
164 { 164 {
165 OverwriteMode = (NOverwriteMode::EEnum)v; 165 OverwriteMode = (NOverwriteMode::EEnum)v;
166 OverwriteMode_Force = true; 166 OverwriteMode_Force = true;
@@ -181,7 +181,7 @@ bool Read_ShowPassword()
181 bool showPassword = false; 181 bool showPassword = false;
182 if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS) 182 if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
183 return showPassword; 183 return showPassword;
184 key.GetValue_IfOk(kShowPassword, showPassword); 184 key.GetValue_bool_IfOk(kShowPassword, showPassword);
185 return showPassword; 185 return showPassword;
186} 186}
187 187
@@ -189,13 +189,10 @@ UInt32 Read_LimitGB()
189{ 189{
190 CS_LOCK 190 CS_LOCK
191 CKey key; 191 CKey key;
192 UInt32 v = (UInt32)(Int32)-1;
192 if (OpenMainKey(key, kKeyName) == ERROR_SUCCESS) 193 if (OpenMainKey(key, kKeyName) == ERROR_SUCCESS)
193 { 194 key.GetValue_UInt32_IfOk(kMemLimit, v);
194 UInt32 v; 195 return v;
195 if (key.QueryValue(kMemLimit, v) == ERROR_SUCCESS)
196 return v;
197 }
198 return (UInt32)(Int32)-1;
199} 196}
200 197
201} 198}
@@ -371,9 +368,9 @@ void CInfo::Load()
371 UString a; 368 UString a;
372 if (key.QueryValue(kArchiver, a) == ERROR_SUCCESS) 369 if (key.QueryValue(kArchiver, a) == ERROR_SUCCESS)
373 ArcType = a; 370 ArcType = a;
374 key.GetValue_IfOk(kLevel, Level); 371 key.GetValue_UInt32_IfOk(kLevel, Level);
375 key.GetValue_IfOk(kShowPassword, ShowPassword); 372 key.GetValue_bool_IfOk(kShowPassword, ShowPassword);
376 key.GetValue_IfOk(kEncryptHeaders, EncryptHeaders); 373 key.GetValue_bool_IfOk(kEncryptHeaders, EncryptHeaders);
377} 374}
378 375
379 376
@@ -517,7 +514,7 @@ void CInfo::Load()
517 return; 514 return;
518 515
519 UInt32 dirType; 516 UInt32 dirType;
520 if (key.QueryValue(kWorkDirType, dirType) != ERROR_SUCCESS) 517 if (key.GetValue_UInt32_IfOk(kWorkDirType, dirType) != ERROR_SUCCESS)
521 return; 518 return;
522 switch (dirType) 519 switch (dirType)
523 { 520 {
@@ -535,7 +532,7 @@ void CInfo::Load()
535 if (Mode == NMode::kSpecified) 532 if (Mode == NMode::kSpecified)
536 Mode = NMode::kSystem; 533 Mode = NMode::kSystem;
537 } 534 }
538 key.GetValue_IfOk(kTempRemovableOnly, ForRemovableOnly); 535 key.GetValue_bool_IfOk(kTempRemovableOnly, ForRemovableOnly);
539} 536}
540 537
541} 538}
@@ -598,5 +595,5 @@ void CContextMenuInfo::Load()
598 595
599 Key_Get_UInt32(key, kWriteZoneId, WriteZone); 596 Key_Get_UInt32(key, kWriteZoneId, WriteZone);
600 597
601 Flags_Def = (key.GetValue_IfOk(kContextMenu, Flags) == ERROR_SUCCESS); 598 Flags_Def = (key.GetValue_UInt32_IfOk(kContextMenu, Flags) == ERROR_SUCCESS);
602} 599}