This commit is contained in:
Igor Pavlov
2023-12-22 17:17:05 +00:00
committed by Kornel
parent ec44a8a070
commit a36c48cece
954 changed files with 42199 additions and 25482 deletions

View File

@@ -7,13 +7,13 @@
#include "BenchCon.h"
#include "ConsoleClose.h"
struct CPrintBenchCallback: public IBenchPrintCallback
struct CPrintBenchCallback Z7_final: public IBenchPrintCallback
{
FILE *_file;
void Print(const char *s);
void NewLine();
HRESULT CheckBreak();
void Print(const char *s) Z7_override;
void NewLine() Z7_override;
HRESULT CheckBreak() Z7_override;
};
void CPrintBenchCallback::Print(const char *s)

View File

@@ -1,7 +1,7 @@
// BenchCon.h
#ifndef __BENCH_CON_H
#define __BENCH_CON_H
#ifndef ZIP7_INC_BENCH_CON_H
#define ZIP7_INC_BENCH_CON_H
#include <stdio.h>

View File

@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /FAcs /Yu"StdAfx.h" /FD /GF /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_LARGE_PAGES" /D "Z7_DEVICE_FILE" /FAcs /Yu"StdAfx.h" /FD /GF /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /Gr /MTd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD CPP /nologo /Gr /MTd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_LARGE_PAGES" /D "Z7_DEVICE_FILE" /FAcs /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -95,7 +95,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_LARGE_PAGES" /D "Z7_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -121,7 +121,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
# ADD CPP /nologo /Gr /MTd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD CPP /nologo /Gr /MTd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "Z7_LONG_PATH" /D "Z7_EXTERNAL_CODECS" /D "Z7_LARGE_PAGES" /D "Z7_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -345,6 +345,10 @@ SOURCE=..\..\..\Windows\Registry.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\SecurityUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Synchronization.h
# End Source File
# Begin Source File
@@ -441,6 +445,14 @@ SOURCE=..\..\..\Common\MyCom.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyGuidDef.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyInitGuid.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyString.cpp
# End Source File
# Begin Source File
@@ -461,6 +473,10 @@ SOURCE=..\..\..\Common\MyVector.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyWindows.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.cpp
# End Source File
# Begin Source File
@@ -757,6 +773,14 @@ SOURCE=..\..\Common\MethodProps.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\MultiOutStream.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\MultiOutStream.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\ProgressUtils.cpp
# End Source File
# Begin Source File
@@ -845,6 +869,10 @@ SOURCE=..\..\..\..\C\7zTypes.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\7zWindows.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -854,6 +882,10 @@ SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Compiler.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\CpuArch.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File

View File

@@ -1,7 +1,7 @@
MY_CONSOLE = 1
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
CFLAGS = $(CFLAGS) -DZ7_LONG_PATH -DZ7_LARGE_PAGES -DZ7_DEVICE_FILE
!ENDIF
CONSOLE_OBJS = \
@@ -41,3 +41,5 @@ UI_COMMON_OBJS = \
C_OBJS = $(C_OBJS) \
$O\DllSecur.obj \
# we need empty line after last line above

View File

@@ -10,4 +10,7 @@
<!-- Win 8.1 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Win 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application></compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware></windowsSettings></application>
</assembly>

View File

@@ -1,7 +1,7 @@
// ConsoleClose.h
#ifndef __CONSOLE_CLOSE_H
#define __CONSOLE_CLOSE_H
#ifndef ZIP7_INC_CONSOLE_CLOSE_H
#define ZIP7_INC_CONSOLE_CLOSE_H
namespace NConsoleClose {
@@ -21,7 +21,7 @@ inline bool TestBreakSignal()
return (g_BreakCounter != 0);
}
class CCtrlHandlerSetter
class CCtrlHandlerSetter Z7_final
{
#ifndef _WIN32
void (*memo_sig_int)(int);
@@ -29,7 +29,7 @@ class CCtrlHandlerSetter
#endif
public:
CCtrlHandlerSetter();
virtual ~CCtrlHandlerSetter();
~CCtrlHandlerSetter();
};
#endif

View File

@@ -11,7 +11,7 @@
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/PropVariantConv.h"
#ifndef _7ZIP_ST
#ifndef Z7_ST
#include "../../../Windows/Synchronization.h"
#endif
@@ -183,7 +183,7 @@ void CExtractScanConsole::PrintStat(const CDirItemsStat &st)
#ifndef _7ZIP_ST
#ifndef Z7_ST
static NSynchronization::CCriticalSection g_CriticalSection;
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
#else
@@ -235,7 +235,7 @@ static const char * const k_ErrorFlagsMessages[] =
, "CRC Error"
};
STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 size)
Z7_COM7F_IMF(CExtractCallbackConsole::SetTotal(UInt64 size))
{
MT_LOCK
@@ -247,7 +247,7 @@ STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64 size)
return CheckBreak2();
}
STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *completeValue)
Z7_COM7F_IMF(CExtractCallbackConsole::SetCompleted(const UInt64 *completeValue))
{
MT_LOCK
@@ -281,14 +281,14 @@ static void PrintFileInfo(CStdOutStream *_so, const wchar_t *path, const FILETIM
}
}
STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
Z7_COM7F_IMF(CExtractCallbackConsole::AskOverwrite(
const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
Int32 *answer)
Int32 *answer))
{
MT_LOCK
RINOK(CheckBreak2());
RINOK(CheckBreak2())
ClosePercentsAndFlush();
@@ -302,7 +302,7 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
NUserAnswerMode::EEnum overwriteAnswer = ScanUserYesNoAllQuit(_so);
switch (overwriteAnswer)
switch ((int)overwriteAnswer)
{
case NUserAnswerMode::kQuit: return E_ABORT;
case NUserAnswerMode::kNo: *answer = NOverwriteAnswer::kNo; break;
@@ -325,7 +325,7 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
return CheckBreak2();
}
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position)
Z7_COM7F_IMF(CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 isFolder, Int32 askExtractMode, const UInt64 *position))
{
MT_LOCK
@@ -341,7 +341,7 @@ STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int3
case NArchive::NExtract::NAskMode::kSkip: s = kSkipString; requiredLevel = 2; break;
case NArchive::NExtract::NAskMode::kReadExternal: s = kReadString; requiredLevel = 0; break;
default: s = "???"; requiredLevel = 2;
};
}
bool show2 = (LogLevel >= requiredLevel && _so);
@@ -394,11 +394,11 @@ STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int3
return CheckBreak2();
}
STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
Z7_COM7F_IMF(CExtractCallbackConsole::MessageError(const wchar_t *message))
{
MT_LOCK
RINOK(CheckBreak2());
RINOK(CheckBreak2())
NumFileErrors_in_Current++;
NumFileErrors++;
@@ -460,7 +460,7 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &dest)
}
}
STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted)
Z7_COM7F_IMF(CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted))
{
MT_LOCK
@@ -499,7 +499,7 @@ STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encr
return CheckBreak2();
}
STDMETHODIMP CExtractCallbackConsole::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name)
Z7_COM7F_IMF(CExtractCallbackConsole::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name))
{
if (opRes != NArchive::NExtract::NOperationResult::kOK)
{
@@ -512,7 +512,7 @@ STDMETHODIMP CExtractCallbackConsole::ReportExtractResult(Int32 opRes, Int32 enc
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
{
@@ -521,7 +521,7 @@ HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
return S_OK;
}
STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
Z7_COM7F_IMF(CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password))
{
COM_TRY_BEGIN
MT_LOCK
@@ -533,7 +533,7 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
{
RINOK(CheckBreak2());
RINOK(CheckBreak2())
NumTryArcs++;
ThereIsError_in_Current = false;
@@ -560,7 +560,7 @@ static AString GetOpenArcErrorMessage(UInt32 errorFlags)
{
AString s;
for (unsigned i = 0; i < ARRAY_SIZE(k_ErrorFlagsMessages); i++)
for (unsigned i = 0; i < Z7_ARRAY_SIZE(k_ErrorFlagsMessages); i++)
{
UInt32 f = (1 << i);
if ((errorFlags & f) == 0)
@@ -739,7 +739,7 @@ HRESULT CExtractCallbackConsole::OpenResult(
{
if (_so)
{
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink));
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink))
*_so << endl;
}
}
@@ -753,8 +753,8 @@ HRESULT CExtractCallbackConsole::OpenResult(
*_se << kError;
_se->NormalizePrint_wstr(name);
*_se << endl;
HRESULT res = Print_OpenArchive_Error(*_se, codecs, arcLink);
RINOK(res);
const HRESULT res = Print_OpenArchive_Error(*_se, codecs, arcLink);
RINOK(res)
if (result == S_FALSE)
{
}

View File

@@ -1,7 +1,7 @@
// ExtractCallbackConsole.h
#ifndef __EXTRACT_CALLBACK_CONSOLE_H
#define __EXTRACT_CALLBACK_CONSOLE_H
#ifndef ZIP7_INC_EXTRACT_CALLBACK_CONSOLE_H
#define ZIP7_INC_EXTRACT_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
@@ -34,8 +34,10 @@ struct CErrorPathCodes2
};
*/
class CExtractScanConsole: public IDirItemsCallback
class CExtractScanConsole Z7_final: public IDirItemsCallback
{
Z7_IFACE_IMP(IDirItemsCallback)
CStdOutStream *_so;
CStdOutStream *_se;
CPercentPrinter _percent;
@@ -54,8 +56,6 @@ class CExtractScanConsole: public IDirItemsCallback
public:
virtual ~CExtractScanConsole() {}
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
_so = outStream;
@@ -67,8 +67,6 @@ public:
void StartScanning();
INTERFACE_IDirItemsCallback(;)
void CloseScanning()
{
if (NeedPercents())
@@ -81,16 +79,36 @@ public:
class CExtractCallbackConsole:
class CExtractCallbackConsole Z7_final:
public IFolderArchiveExtractCallback,
public IExtractCallbackUI,
// public IArchiveExtractCallbackMessage,
public IFolderArchiveExtractCallback2,
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
public ICryptoGetTextPassword,
#endif
#endif
public COpenCallbackConsole,
public CMyUnknownImp
{
Z7_COM_QI_BEGIN2(IFolderArchiveExtractCallback)
// Z7_COM_QI_ENTRY(IArchiveExtractCallbackMessage)
Z7_COM_QI_ENTRY(IFolderArchiveExtractCallback2)
#ifndef Z7_NO_CRYPTO
Z7_COM_QI_ENTRY(ICryptoGetTextPassword)
#endif
Z7_COM_QI_END
Z7_COM_ADDREF_RELEASE
Z7_IFACE_COM7_IMP(IProgress)
Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback)
Z7_IFACE_IMP(IExtractCallbackUI)
// Z7_IFACE_COM7_IMP(IArchiveExtractCallbackMessage)
Z7_IFACE_COM7_IMP(IFolderArchiveExtractCallback2)
#ifndef Z7_NO_CRYPTO
Z7_IFACE_COM7_IMP(ICryptoGetTextPassword)
#endif
AString _tempA;
UString _tempU;
@@ -109,32 +127,7 @@ class CExtractCallbackConsole:
if (_so)
_so->Flush();
}
public:
MY_QUERYINTERFACE_BEGIN2(IFolderArchiveExtractCallback)
// MY_QUERYINTERFACE_ENTRY(IArchiveExtractCallbackMessage)
MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback2)
#ifndef _NO_CRYPTO
MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
#endif
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
STDMETHOD(SetTotal)(UInt64 total);
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
INTERFACE_IFolderArchiveExtractCallback(;)
INTERFACE_IExtractCallbackUI(;)
// INTERFACE_IArchiveExtractCallbackMessage(;)
INTERFACE_IFolderArchiveExtractCallback2(;)
#ifndef _NO_CRYPTO
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
#endif
UInt64 NumTryArcs;
bool ThereIsError_in_Current;

View File

@@ -99,7 +99,7 @@ HRESULT CHashCallbackConsole::SetCompleted(const UInt64 *completeValue)
static void AddMinuses(AString &s, unsigned num)
{
for (unsigned i = 0; i < num; i++)
s += '-';
s.Add_Minus();
}
static void AddSpaces_if_Positive(AString &s, int num)

View File

@@ -1,14 +1,19 @@
// HashCon.h
#ifndef __HASH_CON_H
#define __HASH_CON_H
#ifndef ZIP7_INC_HASH_CON_H
#define ZIP7_INC_HASH_CON_H
#include "../Common/HashCalc.h"
#include "UpdateCallbackConsole.h"
class CHashCallbackConsole: public IHashCallbackUI, public CCallbackConsoleBase
class CHashCallbackConsole Z7_final:
public IHashCallbackUI,
public CCallbackConsoleBase
{
Z7_IFACE_IMP(IDirItemsCallback)
Z7_IFACE_IMP(IHashCallbackUI)
UString _fileName;
AString _s;
@@ -33,9 +38,7 @@ class CHashCallbackConsole: public IHashCallbackUI, public CCallbackConsoleBase
public:
bool PrintNameInPercents;
bool PrintHeaders;
// bool PrintSize;
// bool PrintNewLine; // set it too (false), if you need only hash for single file without LF char.
AString PrintFields;
@@ -48,10 +51,6 @@ public:
// , PrintSize(true),
// , PrintNewLine(true)
{}
virtual ~CHashCallbackConsole() {}
INTERFACE_IHashCallbackUI(;)
};
void PrintHashStat(CStdOutStream &so, const CHashBundle &hb);

View File

@@ -131,6 +131,8 @@ static const char * const kPropIdToName[] =
, "Group ID"
, "Device Major"
, "Device Minor"
, "Dev Major"
, "Dev Minor"
};
static const char kEmptyAttribChar = '.';
@@ -405,13 +407,13 @@ void CFieldPrinter::Init(const CFieldInfoInit *standardFieldTable, unsigned numI
for (k = 0; k < fii.PrefixSpacesWidth; k++)
LinesString.Add_Space();
for (k = 0; k < fii.Width; k++)
LinesString += '-';
LinesString.Add_Minus();
}
}
static void GetPropName(PROPID propID, const wchar_t *name, AString &nameA, UString &nameU)
{
if (propID < ARRAY_SIZE(kPropIdToName))
if (propID < Z7_ARRAY_SIZE(kPropIdToName))
{
nameA = kPropIdToName[propID];
return;
@@ -455,13 +457,13 @@ void CFieldPrinter::AddProp(const wchar_t *name, PROPID propID, bool isRawProp)
HRESULT CFieldPrinter::AddMainProps(IInArchive *archive)
{
UInt32 numProps;
RINOK(archive->GetNumberOfProperties(&numProps));
RINOK(archive->GetNumberOfProperties(&numProps))
for (UInt32 i = 0; i < numProps; i++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
RINOK(archive->GetPropertyInfo(i, &name, &propID, &vt));
RINOK(archive->GetPropertyInfo(i, &name, &propID, &vt))
AddProp(name, propID, false);
}
return S_OK;
@@ -470,12 +472,12 @@ HRESULT CFieldPrinter::AddMainProps(IInArchive *archive)
HRESULT CFieldPrinter::AddRawProps(IArchiveGetRawProps *getRawProps)
{
UInt32 numProps;
RINOK(getRawProps->GetNumRawProps(&numProps));
RINOK(getRawProps->GetNumRawProps(&numProps))
for (UInt32 i = 0; i < numProps; i++)
{
CMyComBSTR name;
PROPID propID;
RINOK(getRawProps->GetRawPropInfo(i, &name, &propID));
RINOK(getRawProps->GetRawPropInfo(i, &name, &propID))
AddProp(name, propID, true);
}
return S_OK;
@@ -516,7 +518,7 @@ static void PrintTime(char *dest, const CListFileTimeDef &t, bool showNS)
ConvertUtcFileTimeToString2(t.FT, t.Ns100, dest, prec);
}
#ifndef _SFX
#ifndef Z7_SFX
static inline char GetHex(Byte value)
{
@@ -585,12 +587,12 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
if (f.IsRawProp)
{
#ifndef _SFX
#ifndef Z7_SFX
const void *data;
UInt32 dataSize;
UInt32 propType;
RINOK(Arc->GetRawProps->GetRawProp(index, f.PropID, &data, &dataSize, &propType));
RINOK(Arc->GetRawProps->GetRawProp(index, f.PropID, &data, &dataSize, &propType))
if (dataSize != 0)
{
@@ -600,7 +602,7 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
{
if (propType != NPropDataType::kRaw)
return E_FAIL;
#ifndef _SFX
#ifndef Z7_SFX
ConvertNtSecureToString((const Byte *)data, dataSize, TempAString);
g_StdOut << TempAString;
needPrint = false;
@@ -654,7 +656,7 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
break;
}
default:
RINOK(Arc->Archive->GetProperty(index, f.PropID, &prop));
RINOK(Arc->Archive->GetProperty(index, f.PropID, &prop))
}
if (f.PropID == kpidAttrib && (prop.vt == VT_EMPTY || prop.vt == VT_UI4))
{
@@ -786,7 +788,7 @@ static HRESULT GetUInt64Value(IInArchive *archive, UInt32 index, PROPID propID,
value.Val = 0;
value.Def = false;
CPropVariant prop;
RINOK(archive->GetProperty(index, propID, &prop));
RINOK(archive->GetProperty(index, propID, &prop))
value.Def = ConvertPropVariantToUInt64(prop, value.Val);
return S_OK;
}
@@ -798,7 +800,7 @@ static HRESULT GetItemMTime(IInArchive *archive, UInt32 index, CListFileTimeDef
t.Clear();
// t.Def = false;
CPropVariant prop;
RINOK(archive->GetProperty(index, kpidMTime, &prop));
RINOK(archive->GetProperty(index, kpidMTime, &prop))
if (prop.vt == VT_FILETIME)
t.Set_From_Prop(prop);
else if (prop.vt != VT_EMPTY)
@@ -815,7 +817,7 @@ static void PrintPropName_and_Eq(CStdOutStream &so, PROPID propID)
{
const char *s;
char temp[16];
if (propID < ARRAY_SIZE(kPropIdToName))
if (propID < Z7_ARRAY_SIZE(kPropIdToName))
s = kPropIdToName[propID];
else
{
@@ -868,7 +870,7 @@ static void PrintPropVal_MultiLine(CStdOutStream &so, const wchar_t *val)
so << "{";
so << endl;
UString_Replace_CRLF_to_LF(s);
so.Normalize_UString__LF_Allowed(s);
so.Normalize_UString_LF_Allowed(s);
so << s;
so << endl;
so << "}";
@@ -919,7 +921,7 @@ static void PrintPropertyPair2(CStdOutStream &so, PROPID propID, const wchar_t *
static HRESULT PrintArcProp(CStdOutStream &so, IInArchive *archive, PROPID propID, const wchar_t *name)
{
CPropVariant prop;
RINOK(archive->GetArchiveProperty(propID, &prop));
RINOK(archive->GetArchiveProperty(propID, &prop))
PrintPropertyPair2(so, propID, name, prop);
return S_OK;
}
@@ -973,20 +975,20 @@ HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const
if (offset != 0)
PrintPropNameAndNumber_Signed(so, kpidOffset, offset);
IInArchive *archive = arc.Archive;
RINOK(PrintArcProp(so, archive, kpidPhySize, NULL));
RINOK(PrintArcProp(so, archive, kpidPhySize, NULL))
if (er.TailSize != 0)
PrintPropNameAndNumber(so, kpidTailSize, er.TailSize);
{
UInt32 numProps;
RINOK(archive->GetNumberOfArchiveProperties(&numProps));
RINOK(archive->GetNumberOfArchiveProperties(&numProps))
for (UInt32 j = 0; j < numProps; j++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
RINOK(archive->GetArchivePropertyInfo(j, &name, &propID, &vt));
RINOK(PrintArcProp(so, archive, propID, name));
RINOK(archive->GetArchivePropertyInfo(j, &name, &propID, &vt))
RINOK(PrintArcProp(so, archive, propID, name))
}
}
@@ -1002,9 +1004,9 @@ HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
RINOK(archive->GetPropertyInfo(j, &name, &propID, &vt));
RINOK(archive->GetPropertyInfo(j, &name, &propID, &vt))
CPropVariant prop;
RINOK(archive->GetProperty(mainIndex, propID, &prop));
RINOK(archive->GetProperty(mainIndex, propID, &prop))
PrintPropertyPair2(so, propID, name, prop);
}
}
@@ -1016,7 +1018,7 @@ HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const
HRESULT Print_OpenArchive_Error(CStdOutStream &so, const CCodecs *codecs, const CArchiveLink &arcLink);
HRESULT Print_OpenArchive_Error(CStdOutStream &so, const CCodecs *codecs, const CArchiveLink &arcLink)
{
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
if (arcLink.PasswordWasAsked)
so << "Cannot open encrypted archive. Wrong password?";
else
@@ -1051,10 +1053,10 @@ HRESULT ListArchives(
bool processAltStreams, bool showAltStreams,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode,
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
bool &passwordEnabled, UString &password,
#endif
#ifndef _SFX
#ifndef Z7_SFX
const CObjectVector<CProperty> *props,
#endif
UInt64 &numErrors,
@@ -1067,7 +1069,7 @@ HRESULT ListArchives(
CFieldPrinter fp;
if (!techMode)
fp.Init(kStandardFieldTable, ARRAY_SIZE(kStandardFieldTable));
fp.Init(kStandardFieldTable, Z7_ARRAY_SIZE(kStandardFieldTable));
CListStat2 stat2total;
@@ -1128,7 +1130,7 @@ HRESULT ListArchives(
COpenCallbackConsole openCallback;
openCallback.Init(&g_StdOut, g_ErrStream, NULL);
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
openCallback.PasswordIsDefined = passwordEnabled;
openCallback.Password = password;
@@ -1142,7 +1144,7 @@ HRESULT ListArchives(
*/
COpenOptions options;
#ifndef _SFX
#ifndef Z7_SFX
options.props = props;
#endif
options.codecs = codecs;
@@ -1229,7 +1231,7 @@ HRESULT ListArchives(
if (enableHeaders)
{
RINOK(Print_OpenArchive_Props(g_StdOut, codecs, arcLink));
RINOK(Print_OpenArchive_Props(g_StdOut, codecs, arcLink))
g_StdOut << endl;
if (techMode)
@@ -1251,17 +1253,17 @@ HRESULT ListArchives(
if (techMode)
{
fp.Clear();
RINOK(fp.AddMainProps(archive));
RINOK(fp.AddMainProps(archive))
if (arc.GetRawProps)
{
RINOK(fp.AddRawProps(arc.GetRawProps));
RINOK(fp.AddRawProps(arc.GetRawProps))
}
}
CListStat2 stat2;
UInt32 numItems;
RINOK(archive->GetNumberOfItems(&numItems));
RINOK(archive->GetNumberOfItems(&numItems))
CReadArcItem item;
UStringVector pathParts;
@@ -1275,12 +1277,12 @@ HRESULT ListArchives(
if (stdInMode && res == E_INVALIDARG)
break;
RINOK(res);
RINOK(res)
if (arc.Ask_Aux)
{
bool isAux;
RINOK(Archive_IsItem_Aux(archive, i, isAux));
RINOK(Archive_IsItem_Aux(archive, i, isAux))
if (isAux)
continue;
}
@@ -1288,12 +1290,12 @@ HRESULT ListArchives(
bool isAltStream = false;
if (arc.Ask_AltStream)
{
RINOK(Archive_IsItem_AltStream(archive, i, isAltStream));
RINOK(Archive_IsItem_AltStream(archive, i, isAltStream))
if (isAltStream && !processAltStreams)
continue;
}
RINOK(Archive_IsItem_Dir(archive, i, fp.IsDir));
RINOK(Archive_IsItem_Dir(archive, i, fp.IsDir))
if (fp.IsDir ? listOptions.ExcludeDirItems : listOptions.ExcludeFileItems)
continue;
@@ -1302,7 +1304,7 @@ HRESULT ListArchives(
{
if (isAltStream)
{
RINOK(arc.GetItem(i, item));
RINOK(arc.GetItem(i, item))
if (!CensorNode_CheckPath(wildcardCensor, item))
continue;
}
@@ -1319,9 +1321,9 @@ HRESULT ListArchives(
CListStat st;
RINOK(GetUInt64Value(archive, i, kpidSize, st.Size));
RINOK(GetUInt64Value(archive, i, kpidPackSize, st.PackSize));
RINOK(GetItemMTime(archive, i, st.MTime));
RINOK(GetUInt64Value(archive, i, kpidSize, st.Size))
RINOK(GetUInt64Value(archive, i, kpidPackSize, st.PackSize))
RINOK(GetItemMTime(archive, i, st.MTime))
if (fp.IsDir)
stat2.NumDirs++;
@@ -1331,7 +1333,7 @@ HRESULT ListArchives(
if (isAltStream && !showAltStreams)
continue;
RINOK(fp.PrintItemInfo(i, st));
RINOK(fp.PrintItemInfo(i, st))
}
UInt64 numStreams = stat2.GetNumStreams();

View File

@@ -1,7 +1,7 @@
// List.h
#ifndef __LIST_H
#define __LIST_H
#ifndef ZIP7_INC_LIST_H
#define ZIP7_INC_LIST_H
#include "../../../Common/Wildcard.h"
@@ -28,10 +28,10 @@ HRESULT ListArchives(
bool processAltStreams, bool showAltStreams,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode,
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
bool &passwordEnabled, UString &password,
#endif
#ifndef _SFX
#ifndef Z7_SFX
const CObjectVector<CProperty> *props,
#endif
UInt64 &errors,

View File

@@ -5,13 +5,39 @@
#include "../../../Common/MyWindows.h"
#ifdef _WIN32
#include <Psapi.h>
#ifndef Z7_OLD_WIN_SDK
#if defined(__MINGW32__) || defined(__MINGW64__)
#include <psapi.h>
#else
#include <Psapi.h>
#endif
#else // Z7_OLD_WIN_SDK
typedef struct _PROCESS_MEMORY_COUNTERS {
DWORD cb;
DWORD PageFaultCount;
SIZE_T PeakWorkingSetSize;
SIZE_T WorkingSetSize;
SIZE_T QuotaPeakPagedPoolUsage;
SIZE_T QuotaPagedPoolUsage;
SIZE_T QuotaPeakNonPagedPoolUsage;
SIZE_T QuotaNonPagedPoolUsage;
SIZE_T PagefileUsage;
SIZE_T PeakPagefileUsage;
} PROCESS_MEMORY_COUNTERS;
typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS;
#endif // Z7_OLD_WIN_SDK
#else // _WIN32
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/times.h>
#endif
#endif // _WIN32
#include "../../../../C/CpuArch.h"
@@ -28,13 +54,14 @@
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/TimeUtils.h"
#include "../../../Windows/FileDir.h"
#include "../Common/ArchiveCommandLine.h"
#include "../Common/Bench.h"
#include "../Common/ExitCode.h"
#include "../Common/Extract.h"
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
#include "../Common/LoadCodecs.h"
#endif
@@ -48,7 +75,7 @@
#include "OpenCallbackConsole.h"
#include "UpdateCallbackConsole.h"
#ifdef PROG_VARIANT_R
#ifdef Z7_PROG_VARIANT_R
#include "../../../../C/7zVersion.h"
#else
#include "../../MyVersion.h"
@@ -59,7 +86,9 @@ using namespace NFile;
using namespace NCommandLineParser;
#ifdef _WIN32
HINSTANCE g_hInstance = 0;
extern
HINSTANCE g_hInstance;
HINSTANCE g_hInstance = NULL;
#endif
extern CStdOutStream *g_StdStream;
@@ -71,19 +100,21 @@ extern const CCodecInfo *g_Codecs[];
extern unsigned g_NumHashers;
extern const CHasherInfo *g_Hashers[];
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
extern
const CExternalCodecs *g_ExternalCodecs_Ptr;
const CExternalCodecs *g_ExternalCodecs_Ptr;
#endif
DECLARE_AND_SET_CLIENT_VERSION_VAR
#if defined(PROG_VARIANT_Z)
#if defined(Z7_PROG_VARIANT_Z)
#define PROG_POSTFIX "z"
#define PROG_POSTFIX_2 " (z)"
#elif defined(PROG_VARIANT_R)
#elif defined(Z7_PROG_VARIANT_R)
#define PROG_POSTFIX "r"
#define PROG_POSTFIX_2 " (r)"
#elif !defined(EXTERNAL_CODECS)
#elif !defined(Z7_EXTERNAL_CODECS)
#define PROG_POSTFIX "a"
#define PROG_POSTFIX_2 " (a)"
#else
@@ -130,12 +161,12 @@ static const char * const kHelpString =
" -mmt[N] : set number of CPU threads\n"
" -mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)\n"
" -o{Directory} : set Output directory\n"
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
" -p{Password} : set Password\n"
#endif
" -r[-|0] : Recurse subdirectories for name search\n"
" -sa{a|e|s} : set Archive name mode\n"
" -scc{UTF-8|WIN|DOS} : set charset for for console input/output\n"
" -scc{UTF-8|WIN|DOS} : set charset for console input/output\n"
" -scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files\n"
" -scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands\n"
" -sdel : delete files after compression\n"
@@ -151,7 +182,7 @@ static const char * const kHelpString =
" -so : write data to stdout\n"
" -spd : disable wildcard matching for file names\n"
" -spe : eliminate duplication of root folder for extract command\n"
" -spf : use fully qualified file paths\n"
" -spf[2] : use fully qualified file paths\n"
" -ssc[-] : set sensitive case mode\n"
" -sse : stop archive creating, if it can't open some input file\n"
" -ssp : do not change Last Access Time of source files while archiving\n"
@@ -177,7 +208,7 @@ static const char * const kUnsupportedArcTypeMessage = "Unsupported archive type
#define kDefaultSfxModule "7zCon.sfx"
MY_ATTR_NORETURN
Z7_ATTR_NORETURN
static void ShowMessageAndThrowException(LPCSTR message, NExitCode::EEnum code)
{
if (g_ErrStream)
@@ -247,9 +278,17 @@ static void ShowProgInfo(CStdOutStream *so)
{
const UInt32 numCpus = NWindows::NSystem::GetNumberOfProcessors();
*so << " Threads:" << numCpus;
const UInt64 openMAX= NWindows::NSystem::Get_File_OPEN_MAX();
*so << " OPEN_MAX:" << openMAX;
{
FString temp;
NDir::MyGetTempPath(temp);
if (!temp.IsEqualTo(STRING_PATH_SEPARATOR "tmp" STRING_PATH_SEPARATOR))
*so << " temp_path:" << temp;
}
}
#ifdef _7ZIP_ASM
#ifdef Z7_7ZIP_ASM
*so << ", ASM";
#endif
@@ -313,6 +352,17 @@ static void PrintUInt32(CStdOutStream &so, UInt32 val, unsigned size)
PrintStringRight(so, s, size);
}
#ifdef Z7_EXTERNAL_CODECS
static void PrintNumber(CStdOutStream &so, UInt32 val, unsigned numDigits)
{
AString s;
s.Add_UInt32(val);
while (s.Len() < numDigits)
s.InsertAtFront('0');
so << s;
}
#endif
static void PrintLibIndex(CStdOutStream &so, int libIndex)
{
if (libIndex >= 0)
@@ -480,8 +530,12 @@ static void PrintMemUsage(const char *s, UInt64 val)
*g_StdStream << " " << s << " Memory =";
PrintNum(SHIFT_SIZE_VALUE(val, 20), 7);
*g_StdStream << " MB";
#ifdef _7ZIP_LARGE_PAGES
/*
*g_StdStream << " =";
PrintNum(SHIFT_SIZE_VALUE(val, 10), 9);
*g_StdStream << " KB";
*/
#ifdef Z7_LARGE_PAGES
AString lp;
Add_LargePages_String(lp);
if (!lp.IsEmpty())
@@ -530,22 +584,27 @@ static void PrintStat()
The program with K32GetProcessMemoryInfo will not work on systems before Win7
// memDefined = GetProcessMemoryInfo(GetCurrentProcess(), &m, sizeof(m));
*/
HMODULE kern = ::GetModuleHandleW(L"kernel32.dll");
Func_GetProcessMemoryInfo my_GetProcessMemoryInfo = (Func_GetProcessMemoryInfo)
(void *)::GetProcAddress(kern, "K32GetProcessMemoryInfo");
const HMODULE kern = ::GetModuleHandleW(L"kernel32.dll");
Func_GetProcessMemoryInfo
my_GetProcessMemoryInfo = Z7_GET_PROC_ADDRESS(
Func_GetProcessMemoryInfo, kern,
"K32GetProcessMemoryInfo");
if (!my_GetProcessMemoryInfo)
{
HMODULE lib = LoadLibraryW(L"Psapi.dll");
const HMODULE lib = LoadLibraryW(L"Psapi.dll");
if (lib)
my_GetProcessMemoryInfo = (Func_GetProcessMemoryInfo)(void *)::GetProcAddress(lib, "GetProcessMemoryInfo");
my_GetProcessMemoryInfo = Z7_GET_PROC_ADDRESS(
Func_GetProcessMemoryInfo, lib,
"GetProcessMemoryInfo");
}
if (my_GetProcessMemoryInfo)
memDefined = my_GetProcessMemoryInfo(GetCurrentProcess(), &m, sizeof(m));
// FreeLibrary(lib);
Func_QueryProcessCycleTime my_QueryProcessCycleTime = (Func_QueryProcessCycleTime)
(void *)::GetProcAddress(kern, "QueryProcessCycleTime");
const
Func_QueryProcessCycleTime
my_QueryProcessCycleTime = Z7_GET_PROC_ADDRESS(
Func_QueryProcessCycleTime, kern,
"QueryProcessCycleTime");
if (my_QueryProcessCycleTime)
cycleDefined = my_QueryProcessCycleTime(GetCurrentProcess(), &cycleTime);
}
@@ -595,6 +654,7 @@ static void PrintStat()
#ifndef UNDER_CE
if (memDefined) PrintMemUsage("Physical", m.PeakWorkingSetSize);
#endif
*g_StdStream << endl;
}
@@ -603,7 +663,7 @@ static void PrintStat()
static UInt64 Get_timeofday_us()
{
struct timeval now;
if (gettimeofday(&now, 0 ) == 0)
if (gettimeofday(&now, NULL) == 0)
return (UInt64)now.tv_sec * 1000000 + (UInt64)now.tv_usec;
return 0;
}
@@ -666,7 +726,7 @@ static void PrintTime(const char *s, UInt64 val, UInt64 total_us, UInt64 kFreq)
*g_StdStream << '%';
}
static void PrintStat(UInt64 startTime)
static void PrintStat(const UInt64 startTime)
{
tms t;
/* clock_t res = */ times(&t);
@@ -722,9 +782,23 @@ int Main2(
#endif
#ifndef _WIN32
UInt64 startTime = Get_timeofday_us();
const UInt64 startTime = Get_timeofday_us();
#endif
/*
{
g_StdOut << "DWORD:" << (unsigned)sizeof(DWORD);
g_StdOut << " LONG:" << (unsigned)sizeof(LONG);
g_StdOut << " long:" << (unsigned)sizeof(long);
#ifdef _WIN64
// g_StdOut << " long long:" << (unsigned)sizeof(long long);
#endif
g_StdOut << " int:" << (unsigned)sizeof(int);
g_StdOut << " void*:" << (unsigned)sizeof(void *);
g_StdOut << endl;
}
*/
UStringVector commandStrings;
#ifdef _WIN32
@@ -778,7 +852,7 @@ int Main2(
CStdOutStream *percentsStream = NULL;
if (options.Number_for_Percents != k_OutStream_disabled)
percentsStream = (options.Number_for_Percents == k_OutStream_stderr) ? &g_StdErr : &g_StdOut;;
percentsStream = (options.Number_for_Percents == k_OutStream_stderr) ? &g_StdErr : &g_StdOut;
if (options.HelpMode)
{
@@ -866,9 +940,9 @@ int Main2(
ThrowException_if_Error(codecs->Load());
Codecs_AddHashArcHandler(codecs);
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
{
g_ExternalCodecs_Ptr = &__externalCodecs;
g_ExternalCodecs_Ptr = &_externalCodecs;
UString s;
codecs->GetCodecsErrorMessage(s);
if (!s.IsEmpty())
@@ -886,7 +960,7 @@ int Main2(
|| options.Command.CommandType == NCommandType::kList
|| options.Command.IsFromUpdateGroup()))
{
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
if (!codecs->MainDll_ErrorPath.IsEmpty())
{
UString s ("Can't load module: ");
@@ -918,12 +992,12 @@ int Main2(
// excludedFormats.Sort();
}
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
if (isExtractGroupCommand
|| options.Command.IsFromUpdateGroup()
|| options.Command.CommandType == NCommandType::kHash
|| options.Command.CommandType == NCommandType::kBenchmark)
ThrowException_if_Error(__externalCodecs.Load());
ThrowException_if_Error(_externalCodecs.Load());
#endif
int retCode = NExitCode::kSuccess;
@@ -943,12 +1017,16 @@ int Main2(
CStdOutStream &so = (g_StdStream ? *g_StdStream : g_StdOut);
unsigned i;
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
so << endl << "Libs:" << endl;
for (i = 0; i < codecs->Libs.Size(); i++)
{
PrintLibIndex(so, (int)i);
so << ' ' << codecs->Libs[i].Path << endl;
const CCodecLib &lib = codecs->Libs[i];
// if (lib.Version != 0)
so << ": " << (lib.Version >> 16) << ".";
PrintNumber(so, lib.Version & 0xffff, 2);
so << " : " << lib.Path << endl;
}
#endif
@@ -963,7 +1041,7 @@ int Main2(
{
const CArcInfoEx &arc = codecs->Formats[i];
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
PrintLibIndex(so, arc.LibIndex);
#else
so << " ";
@@ -1063,10 +1141,10 @@ int Main2(
}
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
UInt32 numMethods;
if (codecs->GetNumMethods(&numMethods) == S_OK)
if (_externalCodecs.GetCodecs->GetNumMethods(&numMethods) == S_OK)
for (UInt32 j = 0; j < numMethods; j++)
{
PrintLibIndex(so, codecs->GetCodec_LibIndex(j));
@@ -1110,9 +1188,9 @@ int Main2(
so << ' ' << codec.Name << endl;
}
#ifdef EXTERNAL_CODECS
#ifdef Z7_EXTERNAL_CODECS
numMethods = codecs->GetNumHashers();
numMethods = _externalCodecs.GetHashers->GetNumHashers();
for (UInt32 j = 0; j < numMethods; j++)
{
PrintLibIndex(so, codecs->GetHasherLibIndex(j));
@@ -1198,7 +1276,7 @@ int Main2(
CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
ecs->PasswordIsDefined = options.PasswordEnabled;
ecs->Password = options.Password;
#endif
@@ -1216,7 +1294,7 @@ int Main2(
COpenCallbackConsole openCallback;
openCallback.Init(g_StdStream, g_ErrStream);
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
openCallback.PasswordIsDefined = options.PasswordEnabled;
openCallback.Password = options.Password;
#endif
@@ -1230,7 +1308,7 @@ int Main2(
eo.YesToAll = options.YesToAll;
eo.TestMode = options.Command.IsTestCommand();
#ifndef _SFX
#ifndef Z7_SFX
eo.Properties = options.Properties;
#endif
@@ -1254,7 +1332,9 @@ int Main2(
ArchivePathsSorted,
ArchivePathsFullSorted,
options.Censor.Pairs.Front().Head,
eo, ecs, ecs, hashCalc, errorMessage, stat);
eo,
ecs, ecs, ecs,
hashCalc, errorMessage, stat);
ecs->ClosePercents();
@@ -1379,7 +1459,7 @@ int Main2(
options.Censor.Pairs.Front().Head,
options.EnableHeaders,
options.TechMode,
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
options.PasswordEnabled,
options.Password,
#endif
@@ -1408,7 +1488,7 @@ int Main2(
COpenCallbackConsole openCallback;
openCallback.Init(g_StdStream, g_ErrStream, percentsStream);
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
bool passwordIsDefined =
(options.PasswordEnabled && !options.Password.IsEmpty());
openCallback.PasswordIsDefined = passwordIsDefined;
@@ -1422,7 +1502,7 @@ int Main2(
if (percentsStream)
callback.SetWindowWidth(consoleWidth);
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
callback.PasswordIsDefined = passwordIsDefined;
callback.AskPassword = (options.PasswordEnabled && options.Password.IsEmpty());
callback.Password = options.Password;

View File

@@ -5,6 +5,7 @@
#ifdef _WIN32
#include "../../../../C/DllSecur.h"
#endif
#include "../../../../C/CpuArch.h"
#include "../../../Common/MyException.h"
#include "../../../Common/StdOutStream.h"
@@ -56,7 +57,44 @@ static void PrintError(const char *message)
#define NT_CHECK_FAIL_ACTION *g_StdStream << "Unsupported Windows version"; return NExitCode::kFatalError;
#endif
int MY_CDECL main
static inline bool CheckIsa()
{
// __try
{
#if defined(__AVX2__)
if (!CPU_IsSupported_AVX2())
return false;
#elif defined(__AVX__)
if (!CPU_IsSupported_AVX())
return false;
#elif defined(__SSE2__) && !defined(MY_CPU_AMD64) || defined(_M_IX86_FP) && (_M_IX86_FP >= 2)
if (!CPU_IsSupported_SSE2())
return false;
#elif defined(__SSE__) && !defined(MY_CPU_AMD64) || defined(_M_IX86_FP) && (_M_IX86_FP >= 1)
if (!CPU_IsSupported_SSE() ||
!CPU_IsSupported_CMOV())
return false;
#endif
/*
__asm
{
_emit 0fH
_emit 038H
_emit 0cbH
_emit (0c0H + 0 * 8 + 0)
}
*/
return true;
}
/*
__except (EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
*/
}
int Z7_CDECL main
(
#ifndef _WIN32
int numArgs, char *args[]
@@ -66,6 +104,14 @@ int MY_CDECL main
g_ErrStream = &g_StdErr;
g_StdStream = &g_StdOut;
// #if (defined(_MSC_VER) && defined(_M_IX86))
if (!CheckIsa())
{
PrintError("ERROR: processor doesn't support required ISA extension");
return NExitCode::kFatalError;
}
// #endif
NT_CHECK
NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
@@ -119,7 +165,7 @@ int MY_CDECL main
}
return (NExitCode::kFatalError);
}
catch(NExitCode::EEnum &exitCode)
catch(NExitCode::EEnum exitCode)
{
FlushStreams();
if (g_ErrStream)

View File

@@ -77,17 +77,17 @@ HRESULT COpenCallbackConsole::Open_Finished()
}
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
{
*password = NULL;
RINOK(CheckBreak2());
RINOK(CheckBreak2())
if (!PasswordIsDefined)
{
ClosePercents();
RINOK(GetPassword_HRESULT(_so, Password));
RINOK(GetPassword_HRESULT(_so, Password))
PasswordIsDefined = true;
}
return StringToBstr(Password, password);

View File

@@ -1,7 +1,7 @@
// OpenCallbackConsole.h
#ifndef __OPEN_CALLBACK_CONSOLE_H
#define __OPEN_CALLBACK_CONSOLE_H
#ifndef ZIP7_INC_OPEN_CALLBACK_CONSOLE_H
#define ZIP7_INC_OPEN_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
@@ -17,10 +17,10 @@ protected:
CStdOutStream *_so;
CStdOutStream *_se;
bool _totalFilesDefined;
// bool _totalBytesDefined;
// UInt64 _totalFiles;
UInt64 _totalBytes;
bool _totalFilesDefined;
// bool _totalBytesDefined;
bool NeedPercents() const { return _percent._so != NULL; }
@@ -35,12 +35,12 @@ public:
}
COpenCallbackConsole():
_totalBytes(0),
_totalFilesDefined(false),
// _totalBytesDefined(false),
_totalBytes(0),
MultiArcMode(false)
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
, PasswordIsDefined(false)
// , PasswordWasAsked(false)
#endif
@@ -56,9 +56,9 @@ public:
_percent._so = percentStream;
}
INTERFACE_IOpenCallbackUI(;)
Z7_IFACE_IMP(IOpenCallbackUI)
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
bool PasswordIsDefined;
// bool PasswordWasAsked;
UString Password;

View File

@@ -79,7 +79,7 @@ void CPercentPrinter::GetPercents()
while (size < kPercentsSize)
{
_s += ' ';
_s.Add_Space();
size++;
}
@@ -125,8 +125,8 @@ void CPercentPrinter::Print()
char s[32];
ConvertUInt64ToString(Files, s);
// unsigned size = (unsigned)strlen(s);
// for (; size < 3; size++) _s += ' ';
_s += ' ';
// for (; size < 3; size++) _s.Add_Space();
_s.Add_Space();
_s += s;
// _s += "f";
}
@@ -134,13 +134,13 @@ void CPercentPrinter::Print()
if (!Command.IsEmpty())
{
_s += ' ';
_s.Add_Space();
_s += Command;
}
if (!FileName.IsEmpty() && _s.Len() < MaxLen)
{
_s += ' ';
_s.Add_Space();
_tempU = FileName;
_so->Normalize_UString(_tempU);

View File

@@ -1,7 +1,7 @@
// PercentPrinter.h
#ifndef __PERCENT_PRINTER_H
#define __PERCENT_PRINTER_H
#ifndef ZIP7_INC_PERCENT_PRINTER_H
#define ZIP7_INC_PERCENT_PRINTER_H
#include "../../../Common/StdOutStream.h"

View File

@@ -1,8 +1,11 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#ifndef ZIP7_INC_STDAFX_H
#define ZIP7_INC_STDAFX_H
#if defined(_MSC_VER) && _MSC_VER >= 1800
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "../../../Common/Common.h"
#endif

View File

@@ -7,7 +7,7 @@
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/FileName.h"
#ifndef _7ZIP_ST
#ifndef Z7_ST
#include "../../../Windows/Synchronization.h"
#endif
@@ -19,7 +19,7 @@
using namespace NWindows;
#ifndef _7ZIP_ST
#ifndef Z7_ST
static NSynchronization::CCriticalSection g_CriticalSection;
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
#else
@@ -136,7 +136,7 @@ HRESULT CUpdateCallbackConsole::OpenResult(
{
if (_so)
{
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink));
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink))
*_so << endl;
}
}
@@ -150,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();
}
}
@@ -333,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;
@@ -681,12 +687,12 @@ HRESULT CUpdateCallbackConsole::ReportUpdateOperation(UInt32 op, const wchar_t *
/*
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
@@ -700,7 +706,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
*password = NULL;
#ifdef _NO_CRYPTO
#ifdef Z7_NO_CRYPTO
*passwordIsDefined = false;
return S_OK;
@@ -711,7 +717,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
{
if (AskPassword)
{
RINOK(GetPassword_HRESULT(_so, Password));
RINOK(GetPassword_HRESULT(_so, Password))
PasswordIsDefined = true;
}
}
@@ -729,7 +735,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
*password = NULL;
#ifdef _NO_CRYPTO
#ifdef Z7_NO_CRYPTO
return E_NOTIMPL;

View File

@@ -1,7 +1,7 @@
// UpdateCallbackConsole.h
#ifndef __UPDATE_CALLBACK_CONSOLE_H
#define __UPDATE_CALLBACK_CONSOLE_H
#ifndef ZIP7_INC_UPDATE_CALLBACK_CONSOLE_H
#define ZIP7_INC_UPDATE_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
@@ -26,6 +26,7 @@ struct CErrorPathCodes
}
};
class CCallbackConsoleBase
{
protected:
@@ -42,7 +43,7 @@ protected:
HRESULT ReadingFileError_Base(const FString &name, DWORD systemError);
public:
bool NeedPercents() const { return _percent._so != NULL; };
bool NeedPercents() const { return _percent._so != NULL; }
bool StdOutMode;
@@ -94,29 +95,32 @@ public:
// void PrintPropInfo(UString &s, PROPID propID, const PROPVARIANT *value);
};
class CUpdateCallbackConsole: public IUpdateCallbackUI2, public CCallbackConsoleBase
class CUpdateCallbackConsole Z7_final:
public IUpdateCallbackUI2,
public CCallbackConsoleBase
{
// void PrintPropPair(const char *name, const wchar_t *val);
Z7_IFACE_IMP(IUpdateCallbackUI)
Z7_IFACE_IMP(IDirItemsCallback)
Z7_IFACE_IMP(IUpdateCallbackUI2)
public:
bool DeleteMessageWasShown;
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
bool PasswordIsDefined;
UString Password;
bool AskPassword;
UString Password;
#endif
CUpdateCallbackConsole():
DeleteMessageWasShown(false)
#ifndef _NO_CRYPTO
#ifndef Z7_NO_CRYPTO
, PasswordIsDefined(false)
, AskPassword(false)
#endif
{}
virtual ~CUpdateCallbackConsole() {}
/*
void Init(CStdOutStream *outStream)
{
@@ -124,7 +128,6 @@ public:
}
*/
// ~CUpdateCallbackConsole() { if (NeedPercents()) _percent.ClosePrint(); }
INTERFACE_IUpdateCallbackUI2(;)
};
#endif

View File

@@ -73,19 +73,26 @@ static bool GetPassword(CStdOutStream *outStream, UString &psw)
#ifdef MY_DISABLE_ECHO
HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
const HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
/*
GetStdHandle() returns
INVALID_HANDLE_VALUE: If the function fails.
NULL : If an application does not have associated standard handles,
such as a service running on an interactive desktop,
and has not redirected them. */
bool wasChanged = false;
DWORD mode = 0;
if (console != INVALID_HANDLE_VALUE && console != 0)
if (console != INVALID_HANDLE_VALUE && console != NULL)
if (GetConsoleMode(console, &mode))
wasChanged = (SetConsoleMode(console, mode & ~(DWORD)ENABLE_ECHO_INPUT) != 0);
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
const bool res = g_StdIn.ScanUStringUntilNewLine(psw);
if (wasChanged)
SetConsoleMode(console, mode);
#else
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
const bool res = g_StdIn.ScanUStringUntilNewLine(psw);
#endif

View File

@@ -1,7 +1,7 @@
// UserInputUtils.h
#ifndef __USER_INPUT_UTILS_H
#define __USER_INPUT_UTILS_H
#ifndef ZIP7_INC_USER_INPUT_UTILS_H
#define ZIP7_INC_USER_INPUT_UTILS_H
#include "../../../Common/StdOutStream.h"

View File

@@ -1,6 +1,6 @@
PROG = 7z.exe
CFLAGS = $(CFLAGS) \
-DEXTERNAL_CODECS \
-DZ7_EXTERNAL_CODECS \
COMMON_OBJS = \
$O\CommandLineParser.obj \
@@ -42,6 +42,7 @@ WIN_OBJS = \
$O\FilterCoder.obj \
$O\LimitedStreams.obj \
$O\MethodProps.obj \
$O\MultiOutStream.obj \
$O\ProgressUtils.obj \
$O\PropId.obj \
$O\StreamObjects.obj \

View File

@@ -9,11 +9,20 @@ IS_NOT_STANDALONE = 1
LOCAL_FLAGS_ST =
MT_OBJS =
ifdef SystemDrive
IS_MINGW = 1
else
ifdef SYSTEMDRIVE
# ifdef OS
IS_MINGW = 1
endif
endif
ifdef ST_MODE
LOCAL_FLAGS_ST = -D_7ZIP_ST
LOCAL_FLAGS_ST = -DZ7_ST
ifdef SystemDrive
ifdef IS_MINGW
MT_OBJS = \
$O/Threads.o \
@@ -31,12 +40,12 @@ endif
LOCAL_FLAGS_WIN=
ifdef SystemDrive
ifdef IS_MINGW
LOCAL_FLAGS_WIN = \
-D_7ZIP_LARGE_PAGES \
-DWIN_LONG_PATH \
-DSUPPORT_DEVICE_FILE \
-DZ7_LARGE_PAGES \
-DZ7_LONG_PATH \
-DZ7_DEVICE_FILE \
SYS_OBJS = \
$O/FileSystem.o \
@@ -57,7 +66,7 @@ endif
LOCAL_FLAGS = \
$(LOCAL_FLAGS_WIN) \
$(LOCAL_FLAGS_ST) \
-DEXTERNAL_CODECS \
-DZ7_EXTERNAL_CODECS \
@@ -138,6 +147,7 @@ WIN_OBJS = \
$O/LimitedStreams.o \
$O/MethodId.o \
$O/MethodProps.o \
$O/MultiOutStream.o \
$O/OffsetStream.o \
$O/OutBuffer.o \
$O/ProgressUtils.o \