This commit is contained in:
Igor Pavlov
2022-06-23 11:43:16 +01:00
committed by Kornel
parent c3529a41f5
commit ec44a8a070
1248 changed files with 15242 additions and 2443 deletions

0
CPP/7zip/UI/Console/BenchCon.cpp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/BenchCon.h Normal file → Executable file
View File

0
CPP/7zip/UI/Console/Console.dsp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/Console.dsw Normal file → Executable file
View File

0
CPP/7zip/UI/Console/Console.mak Normal file → Executable file
View File

0
CPP/7zip/UI/Console/Console.manifest Normal file → Executable file
View File

0
CPP/7zip/UI/Console/ConsoleClose.cpp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/ConsoleClose.h Normal file → Executable file
View File

7
CPP/7zip/UI/Console/ExtractCallbackConsole.cpp Normal file → Executable file
View File

@@ -56,6 +56,9 @@ HRESULT CExtractScanConsole::ScanProgress(const CDirItemsStat &st, const FString
HRESULT CExtractScanConsole::ScanError(const FString &path, DWORD systemError)
{
// 22.00:
// ScanErrors.AddError(path, systemError);
ClosePercentsAndFlush();
if (_se)
@@ -66,6 +69,10 @@ HRESULT CExtractScanConsole::ScanError(const FString &path, DWORD systemError)
_se->Flush();
}
return HRESULT_FROM_WIN32(systemError);
// 22.00: commented
// CommonError(path, systemError, true);
// return S_OK;
}

21
CPP/7zip/UI/Console/ExtractCallbackConsole.h Normal file → Executable file
View File

@@ -15,12 +15,33 @@
#include "OpenCallbackConsole.h"
/*
struct CErrorPathCodes2
{
FStringVector Paths;
CRecordVector<DWORD> Codes;
void AddError(const FString &path, DWORD systemError)
{
Paths.Add(path);
Codes.Add(systemError);
}
void Clear()
{
Paths.Clear();
Codes.Clear();
}
};
*/
class CExtractScanConsole: public IDirItemsCallback
{
CStdOutStream *_so;
CStdOutStream *_se;
CPercentPrinter _percent;
// CErrorPathCodes2 ScanErrors;
bool NeedPercents() const { return _percent._so != NULL; }
void ClosePercentsAndFlush()

0
CPP/7zip/UI/Console/HashCon.cpp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/HashCon.h Normal file → Executable file
View File

72
CPP/7zip/UI/Console/List.cpp Normal file → Executable file
View File

@@ -124,6 +124,13 @@ static const char * const kPropIdToName[] =
, "Read-only"
, "Out Name"
, "Copy Link"
, "ArcFileName"
, "IsHash"
, "Metadata Changed"
, "User ID"
, "Group ID"
, "Device Major"
, "Device Minor"
};
static const char kEmptyAttribChar = '.';
@@ -303,22 +310,18 @@ struct CListUInt64Def
void Add(const CListUInt64Def &v) { if (v.Def) Add(v.Val); }
};
struct CListFileTimeDef
{
FILETIME Val;
bool Def;
CListFileTimeDef(): Def(false) { Val.dwLowDateTime = 0; Val.dwHighDateTime = 0; }
struct CListFileTimeDef: public CArcTime
{
void Update(const CListFileTimeDef &t)
{
if (t.Def && (!Def || CompareFileTime(&Val, &t.Val) < 0))
{
Val = t.Val;
Def = true;
}
if (t.Def && (!Def || CompareWith(t) < 0))
(*this) = t;
}
};
struct CListStat
{
CListUInt64Def Size;
@@ -493,12 +496,24 @@ void CFieldPrinter::PrintTitleLines()
g_StdOut << LinesString;
}
static void PrintTime(char *dest, const FILETIME *ft)
static void PrintTime(char *dest, const CListFileTimeDef &t, bool showNS)
{
*dest = 0;
if (ft->dwLowDateTime == 0 && ft->dwHighDateTime == 0)
if (t.IsZero())
return;
ConvertUtcFileTimeToString(*ft, dest, kTimestampPrintLevel_SEC);
int prec = kTimestampPrintLevel_SEC;
if (showNS)
{
prec = kTimestampPrintLevel_NTFS;
if (t.Prec != 0)
{
prec = t.GetNumDigits();
if (prec < kTimestampPrintLevel_DAY)
prec = kTimestampPrintLevel_NTFS;
}
}
ConvertUtcFileTimeToString2(t.FT, t.Ns100, dest, prec);
}
#ifndef _SFX
@@ -631,7 +646,13 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
{
case kpidSize: if (st.Size.Def) prop = st.Size.Val; break;
case kpidPackSize: if (st.PackSize.Def) prop = st.PackSize.Val; break;
case kpidMTime: if (st.MTime.Def) prop = st.MTime.Val; break;
case kpidMTime:
{
const CListFileTimeDef &mtime = st.MTime;
if (mtime.Def)
prop.SetAsTimeFrom_FT_Prec_Ns100(mtime.FT, mtime.Prec, mtime.Ns100);
break;
}
default:
RINOK(Arc->Archive->GetProperty(index, f.PropID, &prop));
}
@@ -653,7 +674,9 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
}
else if (prop.vt == VT_FILETIME)
{
PrintTime(temp + tempPos, &prop.filetime);
CListFileTimeDef t;
t.Set_From_Prop(prop);
PrintTime(temp + tempPos, t, techMode);
if (techMode)
g_StdOut << temp + tempPos;
else
@@ -726,7 +749,7 @@ void CFieldPrinter::PrintSum(const CListStat &st, UInt64 numDirs, const char *st
char s[64];
s[0] = 0;
if (st.MTime.Def)
PrintTime(s, &st.MTime.Val);
PrintTime(s, st.MTime, false); // showNS
PrintString(f.TextAdjustment, f.Width, s);
}
else if (f.PropID == kpidPath)
@@ -770,16 +793,14 @@ static HRESULT GetUInt64Value(IInArchive *archive, UInt32 index, PROPID propID,
static HRESULT GetItemMTime(IInArchive *archive, UInt32 index, CListFileTimeDef &t)
{
t.Val.dwLowDateTime = 0;
t.Val.dwHighDateTime = 0;
t.Def = false;
/* maybe we could call CArc::GetItemMTime(UInt32 index, CArcTime &ft, bool &defined) here
that can set default timestamp, if not defined */
t.Clear();
// t.Def = false;
CPropVariant prop;
RINOK(archive->GetProperty(index, kpidMTime, &prop));
if (prop.vt == VT_FILETIME)
{
t.Val = prop.filetime;
t.Def = true;
}
t.Set_From_Prop(prop);
else if (prop.vt != VT_EMPTY)
return E_FAIL;
return S_OK;
@@ -879,7 +900,8 @@ static void PrintPropPair(CStdOutStream &so, const char *name, const wchar_t *va
static void PrintPropertyPair2(CStdOutStream &so, PROPID propID, const wchar_t *name, const CPropVariant &prop)
{
UString s;
ConvertPropertyToString2(s, prop, propID);
const int levelTopLimit = 9; // 1ns level
ConvertPropertyToString2(s, prop, propID, levelTopLimit);
if (!s.IsEmpty())
{
AString nameA;
@@ -1249,7 +1271,7 @@ HRESULT ListArchives(
if (NConsoleClose::TestBreakSignal())
return E_ABORT;
HRESULT res = arc.GetItemPath2(i, fp.FilePath);
HRESULT res = arc.GetItem_Path2(i, fp.FilePath);
if (stdInMode && res == E_INVALIDARG)
break;

0
CPP/7zip/UI/Console/List.h Normal file → Executable file
View File

32
CPP/7zip/UI/Console/Main.cpp Normal file → Executable file
View File

@@ -75,6 +75,8 @@ extern const CHasherInfo *g_Hashers[];
const CExternalCodecs *g_ExternalCodecs_Ptr;
#endif
DECLARE_AND_SET_CLIENT_VERSION_VAR
#if defined(PROG_VARIANT_Z)
#define PROG_POSTFIX "z"
#define PROG_POSTFIX_2 " (z)"
@@ -510,7 +512,7 @@ static void PrintStat()
, &creationTimeFT, &exitTimeFT, &kernelTimeFT, &userTimeFT))
return;
FILETIME curTimeFT;
NTime::GetCurUtcFileTime(curTimeFT);
NTime::GetCurUtc_FiTime(curTimeFT);
#ifndef UNDER_CE
@@ -845,7 +847,7 @@ int Main2(
#if !defined(UNDER_CE)
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &consoleInfo))
consoleWidth = (unsigned)consoleInfo.dwSize.X;
consoleWidth = (unsigned)(unsigned short)consoleInfo.dwSize.X;
#endif
#else
@@ -859,7 +861,7 @@ int Main2(
CREATE_CODECS_OBJECT
codecs->CaseSensitiveChange = options.CaseSensitiveChange;
codecs->CaseSensitive_Change = options.CaseSensitive_Change;
codecs->CaseSensitive = options.CaseSensitive;
ThrowException_if_Error(codecs->Load());
Codecs_AddHashArcHandler(codecs);
@@ -952,9 +954,11 @@ int Main2(
so << endl << "Formats:" << endl;
const char * const kArcFlags = "KSNFMGOPBELHXC";
const char * const kArcFlags = "KSNFMGOPBELHXCc+a+m+r+";
const char * const kArcTimeFlags = "wudn";
const unsigned kNumArcFlags = (unsigned)strlen(kArcFlags);
const unsigned kNumArcTimeFlags = (unsigned)strlen(kArcTimeFlags);
for (i = 0; i < codecs->Formats.Size(); i++)
{
const CArcInfoEx &arc = codecs->Formats[i];
@@ -967,12 +971,22 @@ int Main2(
so << (char)(arc.UpdateEnabled ? 'C' : ' ');
for (unsigned b = 0; b < kNumArcFlags; b++)
{
so << (char)
((arc.Flags & ((UInt32)1 << b)) != 0 ? kArcFlags[b] : ' ');
unsigned b;
for (b = 0; b < kNumArcFlags; b++)
so << (char)((arc.Flags & ((UInt32)1 << b)) != 0 ? kArcFlags[b] : '.');
so << ' ';
}
if (arc.TimeFlags != 0)
{
unsigned b;
for (b = 0; b < kNumArcTimeFlags; b++)
so << (char)((arc.TimeFlags & ((UInt32)1 << b)) != 0 ? kArcTimeFlags[b] : '.');
so << arc.Get_DefaultTimePrec();
so << ' ';
}
so << ' ';
PrintString(so, arc.Name, 8);
so << ' ';

0
CPP/7zip/UI/Console/MainAr.cpp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/OpenCallbackConsole.cpp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/OpenCallbackConsole.h Normal file → Executable file
View File

3
CPP/7zip/UI/Console/PercentPrinter.cpp Normal file → Executable file
View File

@@ -63,7 +63,8 @@ void CPercentPrinter::GetPercents()
{
char c = '%';
UInt64 val = 0;
if (Total == (UInt64)(Int64)-1)
if (Total == (UInt64)(Int64)-1 ||
(Total == 0 && Completed != 0))
{
val = Completed >> 20;
c = 'M';

0
CPP/7zip/UI/Console/PercentPrinter.h Normal file → Executable file
View File

0
CPP/7zip/UI/Console/StdAfx.cpp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/StdAfx.h Normal file → Executable file
View File

169
CPP/7zip/UI/Console/UpdateCallbackConsole.cpp Normal file → Executable file
View File

@@ -11,6 +11,8 @@
#include "../../../Windows/Synchronization.h"
#endif
// #include "../Common/PropIDUtils.h"
#include "ConsoleClose.h"
#include "UserInputUtils.h"
#include "UpdateCallbackConsole.h"
@@ -195,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)
{
@@ -519,6 +537,28 @@ HRESULT CCallbackConsoleBase::PrintProgress(const wchar_t *name, bool isDir, con
return CheckBreak2();
}
/*
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)
@@ -562,10 +602,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;
}
@@ -616,6 +665,8 @@ HRESULT CUpdateCallbackConsole::ReportUpdateOperation(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';
@@ -710,3 +761,119 @@ HRESULT CUpdateCallbackConsole::ShowDeleteFile(const wchar_t *name, bool isDir)
}
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;
}
*/

5
CPP/7zip/UI/Console/UpdateCallbackConsole.h Normal file → Executable file
View File

@@ -35,7 +35,8 @@ protected:
CStdOutStream *_se;
void CommonError(const FString &path, DWORD systemError, bool isWarning);
// void CommonError(const char *message);
HRESULT ScanError_Base(const FString &path, DWORD systemError);
HRESULT OpenFileError_Base(const FString &name, DWORD systemError);
HRESULT ReadingFileError_Base(const FString &name, DWORD systemError);
@@ -89,6 +90,8 @@ public:
HRESULT PrintProgress(const wchar_t *name, bool isDir, const char *command, bool showInLog);
// void PrintInfoLine(const UString &s);
// void PrintPropInfo(UString &s, PROPID propID, const PROPVARIANT *value);
};
class CUpdateCallbackConsole: public IUpdateCallbackUI2, public CCallbackConsoleBase

0
CPP/7zip/UI/Console/UserInputUtils.cpp Normal file → Executable file
View File

0
CPP/7zip/UI/Console/UserInputUtils.h Normal file → Executable file
View File

0
CPP/7zip/UI/Console/makefile Normal file → Executable file
View File

0
CPP/7zip/UI/Console/makefile.gcc Normal file → Executable file
View File

0
CPP/7zip/UI/Console/resource.rc Normal file → Executable file
View File