Update to lzma 23.01.

This commit is contained in:
2023-09-24 03:13:03 +01:00
parent 5a6a32f513
commit dda9bcac54
530 changed files with 31937 additions and 14468 deletions

View File

@@ -5,18 +5,21 @@
#include "../../../Common/IntToString.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/FileName.h"
#ifndef _7ZIP_ST
#ifndef Z7_ST
#include "../../../Windows/Synchronization.h"
#endif
// #include "../Common/PropIDUtils.h"
#include "ConsoleClose.h"
#include "UserInputUtils.h"
#include "UpdateCallbackConsole.h"
using namespace NWindows;
#ifndef _7ZIP_ST
#ifndef Z7_ST
static NSynchronization::CCriticalSection g_CriticalSection;
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
#else
@@ -133,7 +136,7 @@ HRESULT CUpdateCallbackConsole::OpenResult(
{
if (_so)
{
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink));
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink))
*_so << endl;
}
}
@@ -147,7 +150,7 @@ HRESULT CUpdateCallbackConsole::OpenResult(
_se->NormalizePrint_wstr(name);
*_se << endl;
HRESULT res = Print_OpenArchive_Error(*_se, codecs, arcLink);
RINOK(res);
RINOK(res)
_se->Flush();
}
}
@@ -194,6 +197,22 @@ void CCallbackConsoleBase::CommonError(const FString &path, DWORD systemError, b
}
}
/*
void CCallbackConsoleBase::CommonError(const char *message)
{
ClosePercents2();
if (_se)
{
if (_so)
_so->Flush();
*_se << endl << kError << message << endl;
_se->Flush();
}
}
*/
HRESULT CCallbackConsoleBase::ScanError_Base(const FString &path, DWORD systemError)
{
@@ -314,6 +333,12 @@ HRESULT CUpdateCallbackConsole::FinishArchive(const CFinishArchiveStat &st)
s += "Archive size: ";
PrintSize_bytes_Smart(s, st.OutArcFileSize);
s.Add_LF();
if (st.IsMultiVolMode)
{
s += "Volumes: ";
s.Add_UInt32(st.NumVolumes);
s.Add_LF();
}
*_so << endl;
*_so << s;
// *_so << endl;
@@ -470,7 +495,7 @@ HRESULT CUpdateCallbackConsole::SetRatioInfo(const UInt64 * /* inSize */, const
return CheckBreak2();
}
HRESULT CCallbackConsoleBase::PrintProgress(const wchar_t *name, const char *command, bool showInLog)
HRESULT CCallbackConsoleBase::PrintProgress(const wchar_t *name, bool isDir, const char *command, bool showInLog)
{
MT_LOCK
@@ -489,6 +514,8 @@ HRESULT CCallbackConsoleBase::PrintProgress(const wchar_t *name, const char *com
if (name)
{
_tempU = name;
if (isDir)
NWindows::NFile::NName::NormalizeDirPathPrefix(_tempU);
_so->Normalize_UString(_tempU);
}
_so->PrintUString(_tempU, _tempA);
@@ -516,7 +543,29 @@ HRESULT CCallbackConsoleBase::PrintProgress(const wchar_t *name, const char *com
return CheckBreak2();
}
HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool /* isDir */, bool isAnti, UInt32 mode)
/*
void CCallbackConsoleBase::PrintInfoLine(const UString &s)
{
if (LogLevel < 1000)
return;
MT_LOCK
const bool show2 = (_so != NULL);
if (show2)
{
ClosePercents_for_so();
_so->PrintUString(s, _tempA);
*_so << endl;
if (NeedFlush)
_so->Flush();
}
}
*/
HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isDir, bool isAnti, UInt32 mode)
{
if (StdOutMode)
return S_OK;
@@ -546,7 +595,7 @@ HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool /* isDir */,
s = "Reading";
}
return PrintProgress(name, s, LogLevel >= requiredLevel);
return PrintProgress(name, isDir, s, LogLevel >= requiredLevel);
}
HRESULT CUpdateCallbackConsole::OpenFileError(const FString &path, DWORD systemError)
@@ -559,10 +608,19 @@ HRESULT CUpdateCallbackConsole::ReadingFileError(const FString &path, DWORD syst
return ReadingFileError_Base(path, systemError);
}
HRESULT CUpdateCallbackConsole::SetOperationResult(Int32)
HRESULT CUpdateCallbackConsole::SetOperationResult(Int32 /* opRes */)
{
MT_LOCK
_percent.Files++;
/*
if (opRes != NArchive::NUpdate::NOperationResult::kOK)
{
if (opRes == NArchive::NUpdate::NOperationResult::kError_FileChanged)
{
CommonError("Input file changed");
}
}
*/
return S_OK;
}
@@ -594,7 +652,7 @@ HRESULT CUpdateCallbackConsole::ReportExtractResult(Int32 opRes, Int32 isEncrypt
}
HRESULT CUpdateCallbackConsole::ReportUpdateOpeartion(UInt32 op, const wchar_t *name, bool /* isDir */)
HRESULT CUpdateCallbackConsole::ReportUpdateOperation(UInt32 op, const wchar_t *name, bool isDir)
{
// if (StdOutMode) return S_OK;
@@ -613,6 +671,8 @@ HRESULT CUpdateCallbackConsole::ReportUpdateOpeartion(UInt32 op, const wchar_t *
case NUpdateNotifyOp::kSkip: s = "."; requiredLevel = 2; break;
case NUpdateNotifyOp::kDelete: s = "D"; requiredLevel = 3; break;
case NUpdateNotifyOp::kHeader: s = "Header creation"; requiredLevel = 100; break;
case NUpdateNotifyOp::kInFileChanged: s = "Size of input file was changed:"; requiredLevel = 10; break;
// case NUpdateNotifyOp::kOpFinished: s = "Finished"; requiredLevel = 100; break;
default:
{
temp[0] = 'o';
@@ -622,17 +682,17 @@ HRESULT CUpdateCallbackConsole::ReportUpdateOpeartion(UInt32 op, const wchar_t *
}
}
return PrintProgress(name, s, LogLevel >= requiredLevel);
return PrintProgress(name, isDir, s, LogLevel >= requiredLevel);
}
/*
HRESULT CUpdateCallbackConsole::SetPassword(const UString &
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
password
#endif
)
{
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
PasswordIsDefined = true;
Password = password;
#endif
@@ -646,7 +706,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
*password = NULL;
#ifdef _NO_CRYPTO
#ifdef Z7_NO_CRYPTO
*passwordIsDefined = false;
return S_OK;
@@ -657,7 +717,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
{
if (AskPassword)
{
RINOK(GetPassword_HRESULT(_so, Password));
RINOK(GetPassword_HRESULT(_so, Password))
PasswordIsDefined = true;
}
}
@@ -675,7 +735,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
*password = NULL;
#ifdef _NO_CRYPTO
#ifdef Z7_NO_CRYPTO
return E_NOTIMPL;
@@ -694,7 +754,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
COM_TRY_END
}
HRESULT CUpdateCallbackConsole::ShowDeleteFile(const wchar_t *name, bool /* isDir */)
HRESULT CUpdateCallbackConsole::ShowDeleteFile(const wchar_t *name, bool isDir)
{
if (StdOutMode)
return S_OK;
@@ -703,7 +763,123 @@ HRESULT CUpdateCallbackConsole::ShowDeleteFile(const wchar_t *name, bool /* isDi
{
if (!name || name[0] == 0)
name = kEmptyFileAlias;
return PrintProgress(name, "D", true);
return PrintProgress(name, isDir, "D", true);
}
return S_OK;
}
/*
void GetPropName(PROPID propID, const wchar_t *name, AString &nameA, UString &nameU);
static void GetPropName(PROPID propID, UString &nameU)
{
AString nameA;
GetPropName(propID, NULL, nameA, nameU);
// if (!nameA.IsEmpty())
nameU = nameA;
}
static void AddPropNamePrefix(UString &s, PROPID propID)
{
UString name;
GetPropName(propID, name);
s += name;
s += " = ";
}
void CCallbackConsoleBase::PrintPropInfo(UString &s, PROPID propID, const PROPVARIANT *value)
{
AddPropNamePrefix(s, propID);
{
UString dest;
const int level = 9; // we show up to ns precision level
ConvertPropertyToString2(dest, *value, propID, level);
s += dest;
}
PrintInfoLine(s);
}
static void Add_IndexType_Index(UString &s, UInt32 indexType, UInt32 index)
{
if (indexType == NArchive::NEventIndexType::kArcProp)
{
}
else
{
if (indexType == NArchive::NEventIndexType::kBlockIndex)
{
s += "#";
}
else if (indexType == NArchive::NEventIndexType::kOutArcIndex)
{
}
else
{
s += "indexType_";
s.Add_UInt32(indexType);
s.Add_Space();
}
s.Add_UInt32(index);
}
s += ": ";
}
HRESULT CUpdateCallbackConsole::ReportProp(UInt32 indexType, UInt32 index, PROPID propID, const PROPVARIANT *value)
{
UString s;
Add_IndexType_Index(s, indexType, index);
PrintPropInfo(s, propID, value);
return S_OK;
}
static inline char GetHex(Byte value)
{
return (char)((value < 10) ? ('0' + value) : ('a' + (value - 10)));
}
static void AddHexToString(UString &dest, const Byte *data, UInt32 size)
{
for (UInt32 i = 0; i < size; i++)
{
Byte b = data[i];
dest += GetHex((Byte)((b >> 4) & 0xF));
dest += GetHex((Byte)(b & 0xF));
}
}
void HashHexToString(char *dest, const Byte *data, UInt32 size);
HRESULT CUpdateCallbackConsole::ReportRawProp(UInt32 indexType, UInt32 index,
PROPID propID, const void *data, UInt32 dataSize, UInt32 propType)
{
UString s;
propType = propType;
Add_IndexType_Index(s, indexType, index);
AddPropNamePrefix(s, propID);
if (propID == kpidChecksum)
{
char temp[k_HashCalc_DigestSize_Max + 8];
HashHexToString(temp, (const Byte *)data, dataSize);
s += temp;
}
else
AddHexToString(s, (const Byte *)data, dataSize);
PrintInfoLine(s);
return S_OK;
}
HRESULT CUpdateCallbackConsole::ReportFinished(UInt32 indexType, UInt32 index, Int32 opRes)
{
UString s;
Add_IndexType_Index(s, indexType, index);
s += "finished";
if (opRes != NArchive::NUpdate::NOperationResult::kOK)
{
s += ": ";
s.Add_UInt32(opRes);
}
PrintInfoLine(s);
return S_OK;
}
*/