Normalize all the line endings

This commit is contained in:
Tino Reichardt
2020-05-31 13:08:03 +02:00
parent d8345ee3b3
commit 9c3c277ad7
1156 changed files with 292304 additions and 292304 deletions

View File

@@ -1,41 +1,41 @@
// BenchCon.cpp
#include "StdAfx.h"
#include "../Common/Bench.h"
#include "BenchCon.h"
#include "ConsoleClose.h"
struct CPrintBenchCallback: public IBenchPrintCallback
{
FILE *_file;
void Print(const char *s);
void NewLine();
HRESULT CheckBreak();
};
void CPrintBenchCallback::Print(const char *s)
{
fputs(s, _file);
}
void CPrintBenchCallback::NewLine()
{
fputc('\n', _file);
}
HRESULT CPrintBenchCallback::CheckBreak()
{
return NConsoleClose::TestBreakSignal() ? E_ABORT: S_OK;
}
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> &props, UInt32 numIterations, FILE *f)
{
CPrintBenchCallback callback;
callback._file = f;
return Bench(EXTERNAL_CODECS_LOC_VARS
&callback, NULL, props, numIterations, true);
}
// BenchCon.cpp
#include "StdAfx.h"
#include "../Common/Bench.h"
#include "BenchCon.h"
#include "ConsoleClose.h"
struct CPrintBenchCallback: public IBenchPrintCallback
{
FILE *_file;
void Print(const char *s);
void NewLine();
HRESULT CheckBreak();
};
void CPrintBenchCallback::Print(const char *s)
{
fputs(s, _file);
}
void CPrintBenchCallback::NewLine()
{
fputc('\n', _file);
}
HRESULT CPrintBenchCallback::CheckBreak()
{
return NConsoleClose::TestBreakSignal() ? E_ABORT: S_OK;
}
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> &props, UInt32 numIterations, FILE *f)
{
CPrintBenchCallback callback;
callback._file = f;
return Bench(EXTERNAL_CODECS_LOC_VARS
&callback, NULL, props, numIterations, true);
}

View File

@@ -1,14 +1,14 @@
// BenchCon.h
#ifndef __BENCH_CON_H
#define __BENCH_CON_H
#include <stdio.h>
#include "../../Common/CreateCoder.h"
#include "../../UI/Common/Property.h"
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> &props, UInt32 numIterations, FILE *f);
#endif
// BenchCon.h
#ifndef __BENCH_CON_H
#define __BENCH_CON_H
#include <stdio.h>
#include "../../Common/CreateCoder.h"
#include "../../UI/Common/Property.h"
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> &props, UInt32 numIterations, FILE *f);
#endif

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Console"=".\Console.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Console"=".\Console.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,43 +1,43 @@
MY_CONSOLE = 1
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
!ENDIF
CONSOLE_OBJS = \
$O\BenchCon.obj \
$O\ConsoleClose.obj \
$O\ExtractCallbackConsole.obj \
$O\HashCon.obj \
$O\List.obj \
$O\Main.obj \
$O\MainAr.obj \
$O\OpenCallbackConsole.obj \
$O\PercentPrinter.obj \
$O\UpdateCallbackConsole.obj \
$O\UserInputUtils.obj \
UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
$O\Bench.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
$O\HashCalc.obj \
$O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
$O\SortUtils.obj \
$O\TempFiles.obj \
$O\Update.obj \
$O\UpdateAction.obj \
$O\UpdateCallback.obj \
$O\UpdatePair.obj \
$O\UpdateProduce.obj \
C_OBJS = $(C_OBJS) \
$O\DllSecur.obj \
MY_CONSOLE = 1
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
!ENDIF
CONSOLE_OBJS = \
$O\BenchCon.obj \
$O\ConsoleClose.obj \
$O\ExtractCallbackConsole.obj \
$O\HashCon.obj \
$O\List.obj \
$O\Main.obj \
$O\MainAr.obj \
$O\OpenCallbackConsole.obj \
$O\PercentPrinter.obj \
$O\UpdateCallbackConsole.obj \
$O\UserInputUtils.obj \
UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
$O\Bench.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
$O\HashCalc.obj \
$O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
$O\SortUtils.obj \
$O\TempFiles.obj \
$O\Update.obj \
$O\UpdateAction.obj \
$O\UpdateCallback.obj \
$O\UpdatePair.obj \
$O\UpdateProduce.obj \
C_OBJS = $(C_OBJS) \
$O\DllSecur.obj \

View File

@@ -1,13 +1,13 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="7z" type="win32"></assemblyIdentity>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security><requestedPrivileges><requestedExecutionLevel level="asInvoker" uiAccess="false">
</requestedExecutionLevel></requestedPrivileges></security></trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application>
<!-- Vista --> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Win 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Win 8 --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Win 8.1 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Win 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application></compatibility>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="7z" type="win32"></assemblyIdentity>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security><requestedPrivileges><requestedExecutionLevel level="asInvoker" uiAccess="false">
</requestedExecutionLevel></requestedPrivileges></security></trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application>
<!-- Vista --> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Win 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Win 8 --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Win 8.1 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Win 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application></compatibility>
</assembly>

View File

@@ -1,69 +1,69 @@
// ConsoleClose.cpp
#include "StdAfx.h"
#include "ConsoleClose.h"
#if !defined(UNDER_CE) && defined(_WIN32)
#include "../../../Common/MyWindows.h"
#endif
namespace NConsoleClose {
unsigned g_BreakCounter = 0;
static const unsigned kBreakAbortThreshold = 2;
#if !defined(UNDER_CE) && defined(_WIN32)
static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
{
if (ctrlType == CTRL_LOGOFF_EVENT)
{
// printf("\nCTRL_LOGOFF_EVENT\n");
return TRUE;
}
g_BreakCounter++;
if (g_BreakCounter < kBreakAbortThreshold)
return TRUE;
return FALSE;
/*
switch (ctrlType)
{
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
if (g_BreakCounter < kBreakAbortThreshold)
return TRUE;
}
return FALSE;
*/
}
#endif
/*
void CheckCtrlBreak()
{
if (TestBreakSignal())
throw CCtrlBreakException();
}
*/
CCtrlHandlerSetter::CCtrlHandlerSetter()
{
#if !defined(UNDER_CE) && defined(_WIN32)
if (!SetConsoleCtrlHandler(HandlerRoutine, TRUE))
throw "SetConsoleCtrlHandler fails";
#endif
}
CCtrlHandlerSetter::~CCtrlHandlerSetter()
{
#if !defined(UNDER_CE) && defined(_WIN32)
if (!SetConsoleCtrlHandler(HandlerRoutine, FALSE))
{
// warning for throw in destructor.
// throw "SetConsoleCtrlHandler fails";
}
#endif
}
}
// ConsoleClose.cpp
#include "StdAfx.h"
#include "ConsoleClose.h"
#if !defined(UNDER_CE) && defined(_WIN32)
#include "../../../Common/MyWindows.h"
#endif
namespace NConsoleClose {
unsigned g_BreakCounter = 0;
static const unsigned kBreakAbortThreshold = 2;
#if !defined(UNDER_CE) && defined(_WIN32)
static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
{
if (ctrlType == CTRL_LOGOFF_EVENT)
{
// printf("\nCTRL_LOGOFF_EVENT\n");
return TRUE;
}
g_BreakCounter++;
if (g_BreakCounter < kBreakAbortThreshold)
return TRUE;
return FALSE;
/*
switch (ctrlType)
{
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
if (g_BreakCounter < kBreakAbortThreshold)
return TRUE;
}
return FALSE;
*/
}
#endif
/*
void CheckCtrlBreak()
{
if (TestBreakSignal())
throw CCtrlBreakException();
}
*/
CCtrlHandlerSetter::CCtrlHandlerSetter()
{
#if !defined(UNDER_CE) && defined(_WIN32)
if (!SetConsoleCtrlHandler(HandlerRoutine, TRUE))
throw "SetConsoleCtrlHandler fails";
#endif
}
CCtrlHandlerSetter::~CCtrlHandlerSetter()
{
#if !defined(UNDER_CE) && defined(_WIN32)
if (!SetConsoleCtrlHandler(HandlerRoutine, FALSE))
{
// warning for throw in destructor.
// throw "SetConsoleCtrlHandler fails";
}
#endif
}
}

View File

@@ -1,33 +1,33 @@
// ConsoleClose.h
#ifndef __CONSOLE_CLOSE_H
#define __CONSOLE_CLOSE_H
namespace NConsoleClose {
extern unsigned g_BreakCounter;
inline bool TestBreakSignal()
{
#ifdef UNDER_CE
return false;
#else
return (g_BreakCounter != 0);
#endif
}
class CCtrlHandlerSetter
{
public:
CCtrlHandlerSetter();
virtual ~CCtrlHandlerSetter();
};
class CCtrlBreakException
{};
// void CheckCtrlBreak();
}
#endif
// ConsoleClose.h
#ifndef __CONSOLE_CLOSE_H
#define __CONSOLE_CLOSE_H
namespace NConsoleClose {
extern unsigned g_BreakCounter;
inline bool TestBreakSignal()
{
#ifdef UNDER_CE
return false;
#else
return (g_BreakCounter != 0);
#endif
}
class CCtrlHandlerSetter
{
public:
CCtrlHandlerSetter();
virtual ~CCtrlHandlerSetter();
};
class CCtrlBreakException
{};
// void CheckCtrlBreak();
}
#endif

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,164 +1,164 @@
// ExtractCallbackConsole.h
#ifndef __EXTRACT_CALLBACK_CONSOLE_H
#define __EXTRACT_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
#include "../../IPassword.h"
#include "../../Archive/IArchive.h"
#include "../Common/ArchiveExtractCallback.h"
#include "PercentPrinter.h"
#include "OpenCallbackConsole.h"
class CExtractScanConsole: public IDirItemsCallback
{
CStdOutStream *_so;
CStdOutStream *_se;
CPercentPrinter _percent;
bool NeedPercents() const { return _percent._so != NULL; }
void ClosePercentsAndFlush()
{
if (NeedPercents())
_percent.ClosePrint(true);
if (_so)
_so->Flush();
}
public:
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
_so = outStream;
_se = errorStream;
_percent._so = percentStream;
}
void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
void StartScanning();
INTERFACE_IDirItemsCallback(;)
void CloseScanning()
{
if (NeedPercents())
_percent.ClosePrint(true);
}
void PrintStat(const CDirItemsStat &st);
};
class CExtractCallbackConsole:
public IExtractCallbackUI,
// public IArchiveExtractCallbackMessage,
public IFolderArchiveExtractCallback2,
#ifndef _NO_CRYPTO
public ICryptoGetTextPassword,
#endif
public COpenCallbackConsole,
public CMyUnknownImp
{
AString _tempA;
UString _tempU;
UString _currentName;
void ClosePercents_for_so()
{
if (NeedPercents() && _so == _percent._so)
_percent.ClosePrint(false);
}
void ClosePercentsAndFlush()
{
if (NeedPercents())
_percent.ClosePrint(true);
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;
bool ThereIsWarning_in_Current;
UInt64 NumOkArcs;
UInt64 NumCantOpenArcs;
UInt64 NumArcsWithError;
UInt64 NumArcsWithWarnings;
UInt64 NumOpenArcErrors;
UInt64 NumOpenArcWarnings;
UInt64 NumFileErrors;
UInt64 NumFileErrors_in_Current;
bool NeedFlush;
unsigned PercentsNameLevel;
unsigned LogLevel;
CExtractCallbackConsole():
NeedFlush(false),
PercentsNameLevel(1),
LogLevel(0)
{}
void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
COpenCallbackConsole::Init(outStream, errorStream, percentStream);
NumTryArcs = 0;
ThereIsError_in_Current = false;
ThereIsWarning_in_Current = false;
NumOkArcs = 0;
NumCantOpenArcs = 0;
NumArcsWithError = 0;
NumArcsWithWarnings = 0;
NumOpenArcErrors = 0;
NumOpenArcWarnings = 0;
NumFileErrors = 0;
NumFileErrors_in_Current = 0;
}
};
#endif
// ExtractCallbackConsole.h
#ifndef __EXTRACT_CALLBACK_CONSOLE_H
#define __EXTRACT_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
#include "../../IPassword.h"
#include "../../Archive/IArchive.h"
#include "../Common/ArchiveExtractCallback.h"
#include "PercentPrinter.h"
#include "OpenCallbackConsole.h"
class CExtractScanConsole: public IDirItemsCallback
{
CStdOutStream *_so;
CStdOutStream *_se;
CPercentPrinter _percent;
bool NeedPercents() const { return _percent._so != NULL; }
void ClosePercentsAndFlush()
{
if (NeedPercents())
_percent.ClosePrint(true);
if (_so)
_so->Flush();
}
public:
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
_so = outStream;
_se = errorStream;
_percent._so = percentStream;
}
void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
void StartScanning();
INTERFACE_IDirItemsCallback(;)
void CloseScanning()
{
if (NeedPercents())
_percent.ClosePrint(true);
}
void PrintStat(const CDirItemsStat &st);
};
class CExtractCallbackConsole:
public IExtractCallbackUI,
// public IArchiveExtractCallbackMessage,
public IFolderArchiveExtractCallback2,
#ifndef _NO_CRYPTO
public ICryptoGetTextPassword,
#endif
public COpenCallbackConsole,
public CMyUnknownImp
{
AString _tempA;
UString _tempU;
UString _currentName;
void ClosePercents_for_so()
{
if (NeedPercents() && _so == _percent._so)
_percent.ClosePrint(false);
}
void ClosePercentsAndFlush()
{
if (NeedPercents())
_percent.ClosePrint(true);
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;
bool ThereIsWarning_in_Current;
UInt64 NumOkArcs;
UInt64 NumCantOpenArcs;
UInt64 NumArcsWithError;
UInt64 NumArcsWithWarnings;
UInt64 NumOpenArcErrors;
UInt64 NumOpenArcWarnings;
UInt64 NumFileErrors;
UInt64 NumFileErrors_in_Current;
bool NeedFlush;
unsigned PercentsNameLevel;
unsigned LogLevel;
CExtractCallbackConsole():
NeedFlush(false),
PercentsNameLevel(1),
LogLevel(0)
{}
void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
COpenCallbackConsole::Init(outStream, errorStream, percentStream);
NumTryArcs = 0;
ThereIsError_in_Current = false;
ThereIsWarning_in_Current = false;
NumOkArcs = 0;
NumCantOpenArcs = 0;
NumArcsWithError = 0;
NumArcsWithWarnings = 0;
NumOpenArcErrors = 0;
NumOpenArcWarnings = 0;
NumFileErrors = 0;
NumFileErrors_in_Current = 0;
}
};
#endif

View File

@@ -1,367 +1,367 @@
// HashCon.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "ConsoleClose.h"
#include "HashCon.h"
static const char * const kEmptyFileAlias = "[Content]";
static const char * const kScanningMessage = "Scanning";
static HRESULT CheckBreak2()
{
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
}
HRESULT CHashCallbackConsole::CheckBreak()
{
return CheckBreak2();
}
HRESULT CHashCallbackConsole::StartScanning()
{
if (PrintHeaders && _so)
*_so << kScanningMessage << endl;
if (NeedPercents())
{
_percent.ClearCurState();
_percent.Command = "Scan";
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::ScanProgress(const CDirItemsStat &st, const FString &path, bool /* isDir */)
{
if (NeedPercents())
{
_percent.Files = st.NumDirs + st.NumFiles + st.NumAltStreams;
_percent.Completed = st.GetTotalBytes();
_percent.FileName = fs2us(path);
_percent.Print();
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::ScanError(const FString &path, DWORD systemError)
{
return ScanError_Base(path, systemError);
}
void Print_DirItemsStat(AString &s, const CDirItemsStat &st);
HRESULT CHashCallbackConsole::FinishScanning(const CDirItemsStat &st)
{
if (NeedPercents())
{
_percent.ClosePrint(true);
_percent.ClearCurState();
}
if (PrintHeaders && _so)
{
Print_DirItemsStat(_s, st);
*_so << _s << endl << endl;
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::SetNumFiles(UInt64 /* numFiles */)
{
return CheckBreak2();
}
HRESULT CHashCallbackConsole::SetTotal(UInt64 size)
{
if (NeedPercents())
{
_percent.Total = size;
_percent.Print();
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::SetCompleted(const UInt64 *completeValue)
{
if (completeValue && NeedPercents())
{
_percent.Completed = *completeValue;
_percent.Print();
}
return CheckBreak2();
}
static void AddMinuses(AString &s, unsigned num)
{
for (unsigned i = 0; i < num; i++)
s += '-';
}
static void AddSpaces_if_Positive(AString &s, int num)
{
for (int i = 0; i < num; i++)
s.Add_Space();
}
static void SetSpacesAndNul(char *s, unsigned num)
{
for (unsigned i = 0; i < num; i++)
s[i] = ' ';
s[num] = 0;
}
static const unsigned kSizeField_Len = 13;
static const unsigned kNameField_Len = 12;
static const unsigned kHashColumnWidth_Min = 4 * 2;
static unsigned GetColumnWidth(unsigned digestSize)
{
unsigned width = digestSize * 2;
return width < kHashColumnWidth_Min ? kHashColumnWidth_Min: width;
}
void CHashCallbackConsole::PrintSeparatorLine(const CObjectVector<CHasherState> &hashers)
{
_s.Empty();
for (unsigned i = 0; i < hashers.Size(); i++)
{
if (i != 0)
_s.Add_Space();
const CHasherState &h = hashers[i];
AddMinuses(_s, GetColumnWidth(h.DigestSize));
}
if (PrintSize)
{
_s.Add_Space();
AddMinuses(_s, kSizeField_Len);
}
if (PrintName)
{
AddSpacesBeforeName();
AddMinuses(_s, kNameField_Len);
}
*_so << _s << endl;
}
HRESULT CHashCallbackConsole::BeforeFirstFile(const CHashBundle &hb)
{
if (PrintHeaders && _so)
{
_s.Empty();
ClosePercents_for_so();
FOR_VECTOR (i, hb.Hashers)
{
if (i != 0)
_s.Add_Space();
const CHasherState &h = hb.Hashers[i];
_s += h.Name;
AddSpaces_if_Positive(_s, (int)GetColumnWidth(h.DigestSize) - (int)h.Name.Len());
}
if (PrintSize)
{
_s.Add_Space();
const AString s2 ("Size");
AddSpaces_if_Positive(_s, (int)kSizeField_Len - (int)s2.Len());
_s += s2;
}
if (PrintName)
{
AddSpacesBeforeName();
_s += "Name";
}
*_so << _s << endl;
PrintSeparatorLine(hb.Hashers);
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::OpenFileError(const FString &path, DWORD systemError)
{
return OpenFileError_Base(path, systemError);
}
HRESULT CHashCallbackConsole::GetStream(const wchar_t *name, bool /* isFolder */)
{
_fileName = name;
if (NeedPercents())
{
if (PrintNameInPercents)
{
_percent.FileName.Empty();
if (name)
_percent.FileName = name;
}
_percent.Print();
}
return CheckBreak2();
}
void CHashCallbackConsole::PrintResultLine(UInt64 fileSize,
const CObjectVector<CHasherState> &hashers, unsigned digestIndex, bool showHash)
{
ClosePercents_for_so();
_s.Empty();
FOR_VECTOR (i, hashers)
{
const CHasherState &h = hashers[i];
char s[k_HashCalc_DigestSize_Max * 2 + 64];
s[0] = 0;
if (showHash)
AddHashHexToString(s, h.Digests[digestIndex], h.DigestSize);
SetSpacesAndNul(s + strlen(s), (int)GetColumnWidth(h.DigestSize) - (int)strlen(s));
if (i != 0)
_s.Add_Space();
_s += s;
}
if (PrintSize)
{
_s.Add_Space();
char s[kSizeField_Len + 32];
char *p = s;
if (showHash)
{
p = s + kSizeField_Len;
ConvertUInt64ToString(fileSize, p);
int numSpaces = kSizeField_Len - (int)strlen(p);
if (numSpaces > 0)
{
p -= (unsigned)numSpaces;
for (unsigned i = 0; i < (unsigned)numSpaces; i++)
p[i] = ' ';
}
}
else
SetSpacesAndNul(s, kSizeField_Len);
_s += p;
}
if (PrintName)
AddSpacesBeforeName();
*_so << _s;
}
HRESULT CHashCallbackConsole::SetOperationResult(UInt64 fileSize, const CHashBundle &hb, bool showHash)
{
if (_so)
{
PrintResultLine(fileSize, hb.Hashers, k_HashCalc_Index_Current, showHash);
if (PrintName)
{
if (_fileName.IsEmpty())
*_so << kEmptyFileAlias;
else
_so->NormalizePrint_UString(_fileName);
}
*_so << endl;
}
if (NeedPercents())
{
_percent.Files++;
_percent.Print();
}
return CheckBreak2();
}
static const char * const k_DigestTitles[] =
{
" : "
, " for data: "
, " for data and names: "
, " for streams and names: "
};
static void PrintSum(CStdOutStream &so, const CHasherState &h, unsigned digestIndex)
{
so << h.Name;
{
AString temp;
AddSpaces_if_Positive(temp, 6 - (int)h.Name.Len());
so << temp;
}
so << k_DigestTitles[digestIndex];
char s[k_HashCalc_DigestSize_Max * 2 + 64];
s[0] = 0;
AddHashHexToString(s, h.Digests[digestIndex], h.DigestSize);
so << s << endl;
}
void PrintHashStat(CStdOutStream &so, const CHashBundle &hb)
{
FOR_VECTOR (i, hb.Hashers)
{
const CHasherState &h = hb.Hashers[i];
PrintSum(so, h, k_HashCalc_Index_DataSum);
if (hb.NumFiles != 1 || hb.NumDirs != 0)
PrintSum(so, h, k_HashCalc_Index_NamesSum);
if (hb.NumAltStreams != 0)
PrintSum(so, h, k_HashCalc_Index_StreamsSum);
so << endl;
}
}
void CHashCallbackConsole::PrintProperty(const char *name, UInt64 value)
{
char s[32];
s[0] = ':';
s[1] = ' ';
ConvertUInt64ToString(value, s + 2);
*_so << name << s << endl;
}
HRESULT CHashCallbackConsole::AfterLastFile(CHashBundle &hb)
{
ClosePercents2();
if (PrintHeaders && _so)
{
PrintSeparatorLine(hb.Hashers);
PrintResultLine(hb.FilesSize, hb.Hashers, k_HashCalc_Index_DataSum, true);
*_so << endl << endl;
if (hb.NumFiles != 1 || hb.NumDirs != 0)
{
if (hb.NumDirs != 0)
PrintProperty("Folders", hb.NumDirs);
PrintProperty("Files", hb.NumFiles);
}
PrintProperty("Size", hb.FilesSize);
if (hb.NumAltStreams != 0)
{
PrintProperty("Alternate streams", hb.NumAltStreams);
PrintProperty("Alternate streams size", hb.AltStreamsSize);
}
*_so << endl;
PrintHashStat(*_so, hb);
}
return S_OK;
}
// HashCon.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "ConsoleClose.h"
#include "HashCon.h"
static const char * const kEmptyFileAlias = "[Content]";
static const char * const kScanningMessage = "Scanning";
static HRESULT CheckBreak2()
{
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
}
HRESULT CHashCallbackConsole::CheckBreak()
{
return CheckBreak2();
}
HRESULT CHashCallbackConsole::StartScanning()
{
if (PrintHeaders && _so)
*_so << kScanningMessage << endl;
if (NeedPercents())
{
_percent.ClearCurState();
_percent.Command = "Scan";
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::ScanProgress(const CDirItemsStat &st, const FString &path, bool /* isDir */)
{
if (NeedPercents())
{
_percent.Files = st.NumDirs + st.NumFiles + st.NumAltStreams;
_percent.Completed = st.GetTotalBytes();
_percent.FileName = fs2us(path);
_percent.Print();
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::ScanError(const FString &path, DWORD systemError)
{
return ScanError_Base(path, systemError);
}
void Print_DirItemsStat(AString &s, const CDirItemsStat &st);
HRESULT CHashCallbackConsole::FinishScanning(const CDirItemsStat &st)
{
if (NeedPercents())
{
_percent.ClosePrint(true);
_percent.ClearCurState();
}
if (PrintHeaders && _so)
{
Print_DirItemsStat(_s, st);
*_so << _s << endl << endl;
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::SetNumFiles(UInt64 /* numFiles */)
{
return CheckBreak2();
}
HRESULT CHashCallbackConsole::SetTotal(UInt64 size)
{
if (NeedPercents())
{
_percent.Total = size;
_percent.Print();
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::SetCompleted(const UInt64 *completeValue)
{
if (completeValue && NeedPercents())
{
_percent.Completed = *completeValue;
_percent.Print();
}
return CheckBreak2();
}
static void AddMinuses(AString &s, unsigned num)
{
for (unsigned i = 0; i < num; i++)
s += '-';
}
static void AddSpaces_if_Positive(AString &s, int num)
{
for (int i = 0; i < num; i++)
s.Add_Space();
}
static void SetSpacesAndNul(char *s, unsigned num)
{
for (unsigned i = 0; i < num; i++)
s[i] = ' ';
s[num] = 0;
}
static const unsigned kSizeField_Len = 13;
static const unsigned kNameField_Len = 12;
static const unsigned kHashColumnWidth_Min = 4 * 2;
static unsigned GetColumnWidth(unsigned digestSize)
{
unsigned width = digestSize * 2;
return width < kHashColumnWidth_Min ? kHashColumnWidth_Min: width;
}
void CHashCallbackConsole::PrintSeparatorLine(const CObjectVector<CHasherState> &hashers)
{
_s.Empty();
for (unsigned i = 0; i < hashers.Size(); i++)
{
if (i != 0)
_s.Add_Space();
const CHasherState &h = hashers[i];
AddMinuses(_s, GetColumnWidth(h.DigestSize));
}
if (PrintSize)
{
_s.Add_Space();
AddMinuses(_s, kSizeField_Len);
}
if (PrintName)
{
AddSpacesBeforeName();
AddMinuses(_s, kNameField_Len);
}
*_so << _s << endl;
}
HRESULT CHashCallbackConsole::BeforeFirstFile(const CHashBundle &hb)
{
if (PrintHeaders && _so)
{
_s.Empty();
ClosePercents_for_so();
FOR_VECTOR (i, hb.Hashers)
{
if (i != 0)
_s.Add_Space();
const CHasherState &h = hb.Hashers[i];
_s += h.Name;
AddSpaces_if_Positive(_s, (int)GetColumnWidth(h.DigestSize) - (int)h.Name.Len());
}
if (PrintSize)
{
_s.Add_Space();
const AString s2 ("Size");
AddSpaces_if_Positive(_s, (int)kSizeField_Len - (int)s2.Len());
_s += s2;
}
if (PrintName)
{
AddSpacesBeforeName();
_s += "Name";
}
*_so << _s << endl;
PrintSeparatorLine(hb.Hashers);
}
return CheckBreak2();
}
HRESULT CHashCallbackConsole::OpenFileError(const FString &path, DWORD systemError)
{
return OpenFileError_Base(path, systemError);
}
HRESULT CHashCallbackConsole::GetStream(const wchar_t *name, bool /* isFolder */)
{
_fileName = name;
if (NeedPercents())
{
if (PrintNameInPercents)
{
_percent.FileName.Empty();
if (name)
_percent.FileName = name;
}
_percent.Print();
}
return CheckBreak2();
}
void CHashCallbackConsole::PrintResultLine(UInt64 fileSize,
const CObjectVector<CHasherState> &hashers, unsigned digestIndex, bool showHash)
{
ClosePercents_for_so();
_s.Empty();
FOR_VECTOR (i, hashers)
{
const CHasherState &h = hashers[i];
char s[k_HashCalc_DigestSize_Max * 2 + 64];
s[0] = 0;
if (showHash)
AddHashHexToString(s, h.Digests[digestIndex], h.DigestSize);
SetSpacesAndNul(s + strlen(s), (int)GetColumnWidth(h.DigestSize) - (int)strlen(s));
if (i != 0)
_s.Add_Space();
_s += s;
}
if (PrintSize)
{
_s.Add_Space();
char s[kSizeField_Len + 32];
char *p = s;
if (showHash)
{
p = s + kSizeField_Len;
ConvertUInt64ToString(fileSize, p);
int numSpaces = kSizeField_Len - (int)strlen(p);
if (numSpaces > 0)
{
p -= (unsigned)numSpaces;
for (unsigned i = 0; i < (unsigned)numSpaces; i++)
p[i] = ' ';
}
}
else
SetSpacesAndNul(s, kSizeField_Len);
_s += p;
}
if (PrintName)
AddSpacesBeforeName();
*_so << _s;
}
HRESULT CHashCallbackConsole::SetOperationResult(UInt64 fileSize, const CHashBundle &hb, bool showHash)
{
if (_so)
{
PrintResultLine(fileSize, hb.Hashers, k_HashCalc_Index_Current, showHash);
if (PrintName)
{
if (_fileName.IsEmpty())
*_so << kEmptyFileAlias;
else
_so->NormalizePrint_UString(_fileName);
}
*_so << endl;
}
if (NeedPercents())
{
_percent.Files++;
_percent.Print();
}
return CheckBreak2();
}
static const char * const k_DigestTitles[] =
{
" : "
, " for data: "
, " for data and names: "
, " for streams and names: "
};
static void PrintSum(CStdOutStream &so, const CHasherState &h, unsigned digestIndex)
{
so << h.Name;
{
AString temp;
AddSpaces_if_Positive(temp, 6 - (int)h.Name.Len());
so << temp;
}
so << k_DigestTitles[digestIndex];
char s[k_HashCalc_DigestSize_Max * 2 + 64];
s[0] = 0;
AddHashHexToString(s, h.Digests[digestIndex], h.DigestSize);
so << s << endl;
}
void PrintHashStat(CStdOutStream &so, const CHashBundle &hb)
{
FOR_VECTOR (i, hb.Hashers)
{
const CHasherState &h = hb.Hashers[i];
PrintSum(so, h, k_HashCalc_Index_DataSum);
if (hb.NumFiles != 1 || hb.NumDirs != 0)
PrintSum(so, h, k_HashCalc_Index_NamesSum);
if (hb.NumAltStreams != 0)
PrintSum(so, h, k_HashCalc_Index_StreamsSum);
so << endl;
}
}
void CHashCallbackConsole::PrintProperty(const char *name, UInt64 value)
{
char s[32];
s[0] = ':';
s[1] = ' ';
ConvertUInt64ToString(value, s + 2);
*_so << name << s << endl;
}
HRESULT CHashCallbackConsole::AfterLastFile(CHashBundle &hb)
{
ClosePercents2();
if (PrintHeaders && _so)
{
PrintSeparatorLine(hb.Hashers);
PrintResultLine(hb.FilesSize, hb.Hashers, k_HashCalc_Index_DataSum, true);
*_so << endl << endl;
if (hb.NumFiles != 1 || hb.NumDirs != 0)
{
if (hb.NumDirs != 0)
PrintProperty("Folders", hb.NumDirs);
PrintProperty("Files", hb.NumFiles);
}
PrintProperty("Size", hb.FilesSize);
if (hb.NumAltStreams != 0)
{
PrintProperty("Alternate streams", hb.NumAltStreams);
PrintProperty("Alternate streams size", hb.AltStreamsSize);
}
*_so << endl;
PrintHashStat(*_so, hb);
}
return S_OK;
}

View File

@@ -1,48 +1,48 @@
// HashCon.h
#ifndef __HASH_CON_H
#define __HASH_CON_H
#include "../Common/HashCalc.h"
#include "UpdateCallbackConsole.h"
class CHashCallbackConsole: public IHashCallbackUI, public CCallbackConsoleBase
{
UString _fileName;
AString _s;
void AddSpacesBeforeName()
{
_s.Add_Space();
_s.Add_Space();
}
void PrintSeparatorLine(const CObjectVector<CHasherState> &hashers);
void PrintResultLine(UInt64 fileSize,
const CObjectVector<CHasherState> &hashers, unsigned digestIndex, bool showHash);
void PrintProperty(const char *name, UInt64 value);
public:
bool PrintNameInPercents;
bool PrintHeaders;
bool PrintSize;
bool PrintName;
CHashCallbackConsole():
PrintNameInPercents(true),
PrintHeaders(false),
PrintSize(true),
PrintName(true)
{}
~CHashCallbackConsole() { }
INTERFACE_IHashCallbackUI(;)
};
void PrintHashStat(CStdOutStream &so, const CHashBundle &hb);
#endif
// HashCon.h
#ifndef __HASH_CON_H
#define __HASH_CON_H
#include "../Common/HashCalc.h"
#include "UpdateCallbackConsole.h"
class CHashCallbackConsole: public IHashCallbackUI, public CCallbackConsoleBase
{
UString _fileName;
AString _s;
void AddSpacesBeforeName()
{
_s.Add_Space();
_s.Add_Space();
}
void PrintSeparatorLine(const CObjectVector<CHasherState> &hashers);
void PrintResultLine(UInt64 fileSize,
const CObjectVector<CHasherState> &hashers, unsigned digestIndex, bool showHash);
void PrintProperty(const char *name, UInt64 value);
public:
bool PrintNameInPercents;
bool PrintHeaders;
bool PrintSize;
bool PrintName;
CHashCallbackConsole():
PrintNameInPercents(true),
PrintHeaders(false),
PrintSize(true),
PrintName(true)
{}
~CHashCallbackConsole() { }
INTERFACE_IHashCallbackUI(;)
};
void PrintHashStat(CStdOutStream &so, const CHashBundle &hb);
#endif

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,27 +1,27 @@
// List.h
#ifndef __LIST_H
#define __LIST_H
#include "../../../Common/Wildcard.h"
#include "../Common/LoadCodecs.h"
HRESULT ListArchives(CCodecs *codecs,
const CObjectVector<COpenType> &types,
const CIntVector &excludedFormats,
bool stdInMode,
UStringVector &archivePaths, UStringVector &archivePathsFull,
bool processAltStreams, bool showAltStreams,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode,
#ifndef _NO_CRYPTO
bool &passwordEnabled, UString &password,
#endif
#ifndef _SFX
const CObjectVector<CProperty> *props,
#endif
UInt64 &errors,
UInt64 &numWarnings);
#endif
// List.h
#ifndef __LIST_H
#define __LIST_H
#include "../../../Common/Wildcard.h"
#include "../Common/LoadCodecs.h"
HRESULT ListArchives(CCodecs *codecs,
const CObjectVector<COpenType> &types,
const CIntVector &excludedFormats,
bool stdInMode,
UStringVector &archivePaths, UStringVector &archivePathsFull,
bool processAltStreams, bool showAltStreams,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode,
#ifndef _NO_CRYPTO
bool &passwordEnabled, UString &password,
#endif
#ifndef _SFX
const CObjectVector<CProperty> *props,
#endif
UInt64 &errors,
UInt64 &numWarnings);
#endif

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,175 +1,175 @@
// MainAr.cpp
#include "StdAfx.h"
#ifdef _WIN32
#include "../../../../C/DllSecur.h"
#endif
#include "../../../Common/MyException.h"
#include "../../../Common/StdOutStream.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/NtCheck.h"
#include "../Common/ArchiveCommandLine.h"
#include "../Common/ExitCode.h"
#include "ConsoleClose.h"
using namespace NWindows;
CStdOutStream *g_StdStream = NULL;
CStdOutStream *g_ErrStream = NULL;
extern int Main2(
#ifndef _WIN32
int numArgs, char *args[]
#endif
);
static const char * const kException_CmdLine_Error_Message = "Command Line Error:";
static const char * const kExceptionErrorMessage = "ERROR:";
static const char * const kUserBreakMessage = "Break signaled";
static const char * const kMemoryExceptionMessage = "ERROR: Can't allocate required memory!";
static const char * const kUnknownExceptionMessage = "Unknown Error";
static const char * const kInternalExceptionMessage = "\n\nInternal Error #";
static void FlushStreams()
{
if (g_StdStream)
g_StdStream->Flush();
}
static void PrintError(const char *message)
{
FlushStreams();
if (g_ErrStream)
*g_ErrStream << "\n\n" << message << endl;
}
#define NT_CHECK_FAIL_ACTION *g_StdStream << "Unsupported Windows version"; return NExitCode::kFatalError;
int MY_CDECL main
(
#ifndef _WIN32
int numArgs, char *args[]
#endif
)
{
g_ErrStream = &g_StdErr;
g_StdStream = &g_StdOut;
NT_CHECK
NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
int res = 0;
try
{
#ifdef _WIN32
My_SetDefaultDllDirectories();
#endif
res = Main2(
#ifndef _WIN32
numArgs, args
#endif
);
}
catch(const CNewException &)
{
PrintError(kMemoryExceptionMessage);
return (NExitCode::kMemoryError);
}
catch(const NConsoleClose::CCtrlBreakException &)
{
PrintError(kUserBreakMessage);
return (NExitCode::kUserBreak);
}
catch(const CMessagePathException &e)
{
PrintError(kException_CmdLine_Error_Message);
if (g_ErrStream)
*g_ErrStream << e << endl;
return (NExitCode::kUserError);
}
catch(const CSystemException &systemError)
{
if (systemError.ErrorCode == E_OUTOFMEMORY)
{
PrintError(kMemoryExceptionMessage);
return (NExitCode::kMemoryError);
}
if (systemError.ErrorCode == E_ABORT)
{
PrintError(kUserBreakMessage);
return (NExitCode::kUserBreak);
}
if (g_ErrStream)
{
PrintError("System ERROR:");
*g_ErrStream << NError::MyFormatMessage(systemError.ErrorCode) << endl;
}
return (NExitCode::kFatalError);
}
catch(NExitCode::EEnum &exitCode)
{
FlushStreams();
if (g_ErrStream)
*g_ErrStream << kInternalExceptionMessage << exitCode << endl;
return (exitCode);
}
catch(const UString &s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(const AString &s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(const char *s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(const wchar_t *s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(int t)
{
if (g_ErrStream)
{
FlushStreams();
*g_ErrStream << kInternalExceptionMessage << t << endl;
return (NExitCode::kFatalError);
}
}
catch(...)
{
PrintError(kUnknownExceptionMessage);
return (NExitCode::kFatalError);
}
return res;
}
// MainAr.cpp
#include "StdAfx.h"
#ifdef _WIN32
#include "../../../../C/DllSecur.h"
#endif
#include "../../../Common/MyException.h"
#include "../../../Common/StdOutStream.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/NtCheck.h"
#include "../Common/ArchiveCommandLine.h"
#include "../Common/ExitCode.h"
#include "ConsoleClose.h"
using namespace NWindows;
CStdOutStream *g_StdStream = NULL;
CStdOutStream *g_ErrStream = NULL;
extern int Main2(
#ifndef _WIN32
int numArgs, char *args[]
#endif
);
static const char * const kException_CmdLine_Error_Message = "Command Line Error:";
static const char * const kExceptionErrorMessage = "ERROR:";
static const char * const kUserBreakMessage = "Break signaled";
static const char * const kMemoryExceptionMessage = "ERROR: Can't allocate required memory!";
static const char * const kUnknownExceptionMessage = "Unknown Error";
static const char * const kInternalExceptionMessage = "\n\nInternal Error #";
static void FlushStreams()
{
if (g_StdStream)
g_StdStream->Flush();
}
static void PrintError(const char *message)
{
FlushStreams();
if (g_ErrStream)
*g_ErrStream << "\n\n" << message << endl;
}
#define NT_CHECK_FAIL_ACTION *g_StdStream << "Unsupported Windows version"; return NExitCode::kFatalError;
int MY_CDECL main
(
#ifndef _WIN32
int numArgs, char *args[]
#endif
)
{
g_ErrStream = &g_StdErr;
g_StdStream = &g_StdOut;
NT_CHECK
NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
int res = 0;
try
{
#ifdef _WIN32
My_SetDefaultDllDirectories();
#endif
res = Main2(
#ifndef _WIN32
numArgs, args
#endif
);
}
catch(const CNewException &)
{
PrintError(kMemoryExceptionMessage);
return (NExitCode::kMemoryError);
}
catch(const NConsoleClose::CCtrlBreakException &)
{
PrintError(kUserBreakMessage);
return (NExitCode::kUserBreak);
}
catch(const CMessagePathException &e)
{
PrintError(kException_CmdLine_Error_Message);
if (g_ErrStream)
*g_ErrStream << e << endl;
return (NExitCode::kUserError);
}
catch(const CSystemException &systemError)
{
if (systemError.ErrorCode == E_OUTOFMEMORY)
{
PrintError(kMemoryExceptionMessage);
return (NExitCode::kMemoryError);
}
if (systemError.ErrorCode == E_ABORT)
{
PrintError(kUserBreakMessage);
return (NExitCode::kUserBreak);
}
if (g_ErrStream)
{
PrintError("System ERROR:");
*g_ErrStream << NError::MyFormatMessage(systemError.ErrorCode) << endl;
}
return (NExitCode::kFatalError);
}
catch(NExitCode::EEnum &exitCode)
{
FlushStreams();
if (g_ErrStream)
*g_ErrStream << kInternalExceptionMessage << exitCode << endl;
return (exitCode);
}
catch(const UString &s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(const AString &s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(const char *s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(const wchar_t *s)
{
if (g_ErrStream)
{
PrintError(kExceptionErrorMessage);
*g_ErrStream << s << endl;
}
return (NExitCode::kFatalError);
}
catch(int t)
{
if (g_ErrStream)
{
FlushStreams();
*g_ErrStream << kInternalExceptionMessage << t << endl;
return (NExitCode::kFatalError);
}
}
catch(...)
{
PrintError(kUnknownExceptionMessage);
return (NExitCode::kFatalError);
}
return res;
}

View File

@@ -1,115 +1,115 @@
// OpenCallbackConsole.cpp
#include "StdAfx.h"
#include "OpenCallbackConsole.h"
#include "ConsoleClose.h"
#include "UserInputUtils.h"
static HRESULT CheckBreak2()
{
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
}
HRESULT COpenCallbackConsole::Open_CheckBreak()
{
return CheckBreak2();
}
HRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *files, const UInt64 *bytes)
{
if (!MultiArcMode && NeedPercents())
{
if (files)
{
_totalFilesDefined = true;
// _totalFiles = *files;
_percent.Total = *files;
}
else
_totalFilesDefined = false;
if (bytes)
{
// _totalBytesDefined = true;
_totalBytes = *bytes;
if (!files)
_percent.Total = *bytes;
}
else
{
// _totalBytesDefined = false;
if (!files)
_percent.Total = _totalBytes;
}
}
return CheckBreak2();
}
HRESULT COpenCallbackConsole::Open_SetCompleted(const UInt64 *files, const UInt64 *bytes)
{
if (!MultiArcMode && NeedPercents())
{
if (files)
{
_percent.Files = *files;
if (_totalFilesDefined)
_percent.Completed = *files;
}
if (bytes)
{
if (!_totalFilesDefined)
_percent.Completed = *bytes;
}
_percent.Print();
}
return CheckBreak2();
}
HRESULT COpenCallbackConsole::Open_Finished()
{
ClosePercents();
return S_OK;
}
#ifndef _NO_CRYPTO
HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
{
*password = NULL;
RINOK(CheckBreak2());
if (!PasswordIsDefined)
{
ClosePercents();
RINOK(GetPassword_HRESULT(_so, Password));
PasswordIsDefined = true;
}
return StringToBstr(Password, password);
}
/*
HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password)
{
passwordIsDefined = PasswordIsDefined;
password = Password;
return S_OK;
}
bool COpenCallbackConsole::Open_WasPasswordAsked()
{
return PasswordWasAsked;
}
void COpenCallbackConsole::Open_Clear_PasswordWasAsked_Flag ()
{
PasswordWasAsked = false;
}
*/
#endif
// OpenCallbackConsole.cpp
#include "StdAfx.h"
#include "OpenCallbackConsole.h"
#include "ConsoleClose.h"
#include "UserInputUtils.h"
static HRESULT CheckBreak2()
{
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
}
HRESULT COpenCallbackConsole::Open_CheckBreak()
{
return CheckBreak2();
}
HRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *files, const UInt64 *bytes)
{
if (!MultiArcMode && NeedPercents())
{
if (files)
{
_totalFilesDefined = true;
// _totalFiles = *files;
_percent.Total = *files;
}
else
_totalFilesDefined = false;
if (bytes)
{
// _totalBytesDefined = true;
_totalBytes = *bytes;
if (!files)
_percent.Total = *bytes;
}
else
{
// _totalBytesDefined = false;
if (!files)
_percent.Total = _totalBytes;
}
}
return CheckBreak2();
}
HRESULT COpenCallbackConsole::Open_SetCompleted(const UInt64 *files, const UInt64 *bytes)
{
if (!MultiArcMode && NeedPercents())
{
if (files)
{
_percent.Files = *files;
if (_totalFilesDefined)
_percent.Completed = *files;
}
if (bytes)
{
if (!_totalFilesDefined)
_percent.Completed = *bytes;
}
_percent.Print();
}
return CheckBreak2();
}
HRESULT COpenCallbackConsole::Open_Finished()
{
ClosePercents();
return S_OK;
}
#ifndef _NO_CRYPTO
HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
{
*password = NULL;
RINOK(CheckBreak2());
if (!PasswordIsDefined)
{
ClosePercents();
RINOK(GetPassword_HRESULT(_so, Password));
PasswordIsDefined = true;
}
return StringToBstr(Password, password);
}
/*
HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password)
{
passwordIsDefined = PasswordIsDefined;
password = Password;
return S_OK;
}
bool COpenCallbackConsole::Open_WasPasswordAsked()
{
return PasswordWasAsked;
}
void COpenCallbackConsole::Open_Clear_PasswordWasAsked_Flag ()
{
PasswordWasAsked = false;
}
*/
#endif

View File

@@ -1,66 +1,66 @@
// OpenCallbackConsole.h
#ifndef __OPEN_CALLBACK_CONSOLE_H
#define __OPEN_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
#include "../Common/ArchiveOpenCallback.h"
#include "PercentPrinter.h"
class COpenCallbackConsole: public IOpenCallbackUI
{
protected:
CPercentPrinter _percent;
CStdOutStream *_so;
CStdOutStream *_se;
bool _totalFilesDefined;
// bool _totalBytesDefined;
// UInt64 _totalFiles;
UInt64 _totalBytes;
bool NeedPercents() const { return _percent._so != NULL; }
public:
bool MultiArcMode;
void ClosePercents()
{
if (NeedPercents())
_percent.ClosePrint(true);
}
COpenCallbackConsole():
_totalFilesDefined(false),
// _totalBytesDefined(false),
_totalBytes(0),
MultiArcMode(false)
#ifndef _NO_CRYPTO
, PasswordIsDefined(false)
// , PasswordWasAsked(false)
#endif
{}
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
_so = outStream;
_se = errorStream;
_percent._so = percentStream;
}
INTERFACE_IOpenCallbackUI(;)
#ifndef _NO_CRYPTO
bool PasswordIsDefined;
// bool PasswordWasAsked;
UString Password;
#endif
};
#endif
// OpenCallbackConsole.h
#ifndef __OPEN_CALLBACK_CONSOLE_H
#define __OPEN_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
#include "../Common/ArchiveOpenCallback.h"
#include "PercentPrinter.h"
class COpenCallbackConsole: public IOpenCallbackUI
{
protected:
CPercentPrinter _percent;
CStdOutStream *_so;
CStdOutStream *_se;
bool _totalFilesDefined;
// bool _totalBytesDefined;
// UInt64 _totalFiles;
UInt64 _totalBytes;
bool NeedPercents() const { return _percent._so != NULL; }
public:
bool MultiArcMode;
void ClosePercents()
{
if (NeedPercents())
_percent.ClosePrint(true);
}
COpenCallbackConsole():
_totalFilesDefined(false),
// _totalBytesDefined(false),
_totalBytes(0),
MultiArcMode(false)
#ifndef _NO_CRYPTO
, PasswordIsDefined(false)
// , PasswordWasAsked(false)
#endif
{}
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
_so = outStream;
_se = errorStream;
_percent._so = percentStream;
}
INTERFACE_IOpenCallbackUI(;)
#ifndef _NO_CRYPTO
bool PasswordIsDefined;
// bool PasswordWasAsked;
UString Password;
#endif
};
#endif

View File

@@ -1,183 +1,183 @@
// PercentPrinter.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "PercentPrinter.h"
static const unsigned kPercentsSize = 4;
CPercentPrinter::~CPercentPrinter()
{
ClosePrint(false);
}
void CPercentPrinterState::ClearCurState()
{
Completed = 0;
Total = ((UInt64)(Int64)-1);
Files = 0;
Command.Empty();
FileName.Empty();
}
void CPercentPrinter::ClosePrint(bool needFlush)
{
unsigned num = _printedString.Len();
if (num != 0)
{
unsigned i;
/* '\r' in old MAC OS means "new line".
So we can't use '\r' in some systems */
#ifdef _WIN32
char *start = _temp.GetBuf(num + 2);
char *p = start;
*p++ = '\r';
for (i = 0; i < num; i++) *p++ = ' ';
*p++ = '\r';
#else
char *start = _temp.GetBuf(num * 3);
char *p = start;
for (i = 0; i < num; i++) *p++ = '\b';
for (i = 0; i < num; i++) *p++ = ' ';
for (i = 0; i < num; i++) *p++ = '\b';
#endif
*p = 0;
_temp.ReleaseBuf_SetLen((unsigned)(p - start));
*_so << _temp;
}
if (needFlush)
_so->Flush();
_printedString.Empty();
}
void CPercentPrinter::GetPercents()
{
char s[32];
unsigned size;
{
char c = '%';
UInt64 val = 0;
if (Total == (UInt64)(Int64)-1)
{
val = Completed >> 20;
c = 'M';
}
else if (Total != 0)
val = Completed * 100 / Total;
ConvertUInt64ToString(val, s);
size = (unsigned)strlen(s);
s[size++] = c;
s[size] = 0;
}
while (size < kPercentsSize)
{
_s += ' ';
size++;
}
_s += s;
}
void CPercentPrinter::Print()
{
DWORD tick = 0;
if (_tickStep != 0)
tick = GetTickCount();
bool onlyPercentsChanged = false;
if (!_printedString.IsEmpty())
{
if (_tickStep != 0 && (UInt32)(tick - _prevTick) < _tickStep)
return;
CPercentPrinterState &st = *this;
if (_printedState.Command == st.Command
&& _printedState.FileName == st.FileName
&& _printedState.Files == st.Files)
{
if (_printedState.Total == st.Total
&& _printedState.Completed == st.Completed)
return;
onlyPercentsChanged = true;
}
}
_s.Empty();
GetPercents();
if (onlyPercentsChanged && _s == _printedPercents)
return;
_printedPercents = _s;
if (Files != 0)
{
char s[32];
ConvertUInt64ToString(Files, s);
// unsigned size = (unsigned)strlen(s);
// for (; size < 3; size++) _s += ' ';
_s += ' ';
_s += s;
// _s += "f";
}
if (!Command.IsEmpty())
{
_s += ' ';
_s += Command;
}
if (!FileName.IsEmpty() && _s.Len() < MaxLen)
{
_s += ' ';
_tempU = FileName;
_so->Normalize_UString(_tempU);
StdOut_Convert_UString_to_AString(_tempU, _temp);
if (_s.Len() + _temp.Len() > MaxLen)
{
unsigned len = FileName.Len();
for (; len != 0;)
{
unsigned delta = len / 8;
if (delta == 0)
delta = 1;
len -= delta;
_tempU = FileName;
_tempU.Delete(len / 2, _tempU.Len() - len);
_tempU.Insert(len / 2, L" . ");
_so->Normalize_UString(_tempU);
StdOut_Convert_UString_to_AString(_tempU, _temp);
if (_s.Len() + _temp.Len() <= MaxLen)
break;
}
if (len == 0)
_temp.Empty();
}
_s += _temp;
}
if (_printedString != _s)
{
ClosePrint(false);
*_so << _s;
if (NeedFlush)
_so->Flush();
_printedString = _s;
}
_printedState = *this;
if (_tickStep != 0)
_prevTick = tick;
}
// PercentPrinter.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "PercentPrinter.h"
static const unsigned kPercentsSize = 4;
CPercentPrinter::~CPercentPrinter()
{
ClosePrint(false);
}
void CPercentPrinterState::ClearCurState()
{
Completed = 0;
Total = ((UInt64)(Int64)-1);
Files = 0;
Command.Empty();
FileName.Empty();
}
void CPercentPrinter::ClosePrint(bool needFlush)
{
unsigned num = _printedString.Len();
if (num != 0)
{
unsigned i;
/* '\r' in old MAC OS means "new line".
So we can't use '\r' in some systems */
#ifdef _WIN32
char *start = _temp.GetBuf(num + 2);
char *p = start;
*p++ = '\r';
for (i = 0; i < num; i++) *p++ = ' ';
*p++ = '\r';
#else
char *start = _temp.GetBuf(num * 3);
char *p = start;
for (i = 0; i < num; i++) *p++ = '\b';
for (i = 0; i < num; i++) *p++ = ' ';
for (i = 0; i < num; i++) *p++ = '\b';
#endif
*p = 0;
_temp.ReleaseBuf_SetLen((unsigned)(p - start));
*_so << _temp;
}
if (needFlush)
_so->Flush();
_printedString.Empty();
}
void CPercentPrinter::GetPercents()
{
char s[32];
unsigned size;
{
char c = '%';
UInt64 val = 0;
if (Total == (UInt64)(Int64)-1)
{
val = Completed >> 20;
c = 'M';
}
else if (Total != 0)
val = Completed * 100 / Total;
ConvertUInt64ToString(val, s);
size = (unsigned)strlen(s);
s[size++] = c;
s[size] = 0;
}
while (size < kPercentsSize)
{
_s += ' ';
size++;
}
_s += s;
}
void CPercentPrinter::Print()
{
DWORD tick = 0;
if (_tickStep != 0)
tick = GetTickCount();
bool onlyPercentsChanged = false;
if (!_printedString.IsEmpty())
{
if (_tickStep != 0 && (UInt32)(tick - _prevTick) < _tickStep)
return;
CPercentPrinterState &st = *this;
if (_printedState.Command == st.Command
&& _printedState.FileName == st.FileName
&& _printedState.Files == st.Files)
{
if (_printedState.Total == st.Total
&& _printedState.Completed == st.Completed)
return;
onlyPercentsChanged = true;
}
}
_s.Empty();
GetPercents();
if (onlyPercentsChanged && _s == _printedPercents)
return;
_printedPercents = _s;
if (Files != 0)
{
char s[32];
ConvertUInt64ToString(Files, s);
// unsigned size = (unsigned)strlen(s);
// for (; size < 3; size++) _s += ' ';
_s += ' ';
_s += s;
// _s += "f";
}
if (!Command.IsEmpty())
{
_s += ' ';
_s += Command;
}
if (!FileName.IsEmpty() && _s.Len() < MaxLen)
{
_s += ' ';
_tempU = FileName;
_so->Normalize_UString(_tempU);
StdOut_Convert_UString_to_AString(_tempU, _temp);
if (_s.Len() + _temp.Len() > MaxLen)
{
unsigned len = FileName.Len();
for (; len != 0;)
{
unsigned delta = len / 8;
if (delta == 0)
delta = 1;
len -= delta;
_tempU = FileName;
_tempU.Delete(len / 2, _tempU.Len() - len);
_tempU.Insert(len / 2, L" . ");
_so->Normalize_UString(_tempU);
StdOut_Convert_UString_to_AString(_tempU, _temp);
if (_s.Len() + _temp.Len() <= MaxLen)
break;
}
if (len == 0)
_temp.Empty();
}
_s += _temp;
}
if (_printedString != _s)
{
ClosePrint(false);
*_so << _s;
if (NeedFlush)
_so->Flush();
_printedString = _s;
}
_printedState = *this;
if (_tickStep != 0)
_prevTick = tick;
}

View File

@@ -1,62 +1,62 @@
// PercentPrinter.h
#ifndef __PERCENT_PRINTER_H
#define __PERCENT_PRINTER_H
#include "../../../Common/StdOutStream.h"
struct CPercentPrinterState
{
UInt64 Completed;
UInt64 Total;
UInt64 Files;
AString Command;
UString FileName;
void ClearCurState();
CPercentPrinterState():
Completed(0),
Total((UInt64)(Int64)-1),
Files(0)
{}
};
class CPercentPrinter: public CPercentPrinterState
{
UInt32 _tickStep;
DWORD _prevTick;
AString _s;
AString _printedString;
AString _temp;
UString _tempU;
CPercentPrinterState _printedState;
AString _printedPercents;
void GetPercents();
public:
CStdOutStream *_so;
bool NeedFlush;
unsigned MaxLen;
CPercentPrinter(UInt32 tickStep = 200):
_tickStep(tickStep),
_prevTick(0),
NeedFlush(true),
MaxLen(80 - 1)
{}
~CPercentPrinter();
void ClosePrint(bool needFlush);
void Print();
};
#endif
// PercentPrinter.h
#ifndef __PERCENT_PRINTER_H
#define __PERCENT_PRINTER_H
#include "../../../Common/StdOutStream.h"
struct CPercentPrinterState
{
UInt64 Completed;
UInt64 Total;
UInt64 Files;
AString Command;
UString FileName;
void ClearCurState();
CPercentPrinterState():
Completed(0),
Total((UInt64)(Int64)-1),
Files(0)
{}
};
class CPercentPrinter: public CPercentPrinterState
{
UInt32 _tickStep;
DWORD _prevTick;
AString _s;
AString _printedString;
AString _temp;
UString _tempU;
CPercentPrinterState _printedState;
AString _printedPercents;
void GetPercents();
public:
CStdOutStream *_so;
bool NeedFlush;
unsigned MaxLen;
CPercentPrinter(UInt32 tickStep = 200):
_tickStep(tickStep),
_prevTick(0),
NeedFlush(true),
MaxLen(80 - 1)
{}
~CPercentPrinter();
void ClosePrint(bool needFlush);
void Print();
};
#endif

View File

@@ -1,3 +1,3 @@
// StdAfx.cpp
#include "StdAfx.h"
// StdAfx.cpp
#include "StdAfx.h"

View File

@@ -1,8 +1,8 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/Common.h"
#endif
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/Common.h"
#endif

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,124 +1,124 @@
// UpdateCallbackConsole.h
#ifndef __UPDATE_CALLBACK_CONSOLE_H
#define __UPDATE_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
#include "../Common/Update.h"
#include "PercentPrinter.h"
struct CErrorPathCodes
{
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 CCallbackConsoleBase
{
protected:
CPercentPrinter _percent;
CStdOutStream *_so;
CStdOutStream *_se;
void CommonError(const FString &path, DWORD systemError, bool isWarning);
HRESULT ScanError_Base(const FString &path, DWORD systemError);
HRESULT OpenFileError_Base(const FString &name, DWORD systemError);
HRESULT ReadingFileError_Base(const FString &name, DWORD systemError);
public:
bool NeedPercents() const { return _percent._so != NULL; };
bool StdOutMode;
bool NeedFlush;
unsigned PercentsNameLevel;
unsigned LogLevel;
AString _tempA;
UString _tempU;
CCallbackConsoleBase():
StdOutMode(false),
NeedFlush(false),
PercentsNameLevel(1),
LogLevel(0)
{}
void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
FailedFiles.Clear();
_so = outStream;
_se = errorStream;
_percent._so = percentStream;
}
void ClosePercents2()
{
if (NeedPercents())
_percent.ClosePrint(true);
}
void ClosePercents_for_so()
{
if (NeedPercents() && _so == _percent._so)
_percent.ClosePrint(false);
}
CErrorPathCodes FailedFiles;
CErrorPathCodes ScanErrors;
HRESULT PrintProgress(const wchar_t *name, const char *command, bool showInLog);
};
class CUpdateCallbackConsole: public IUpdateCallbackUI2, public CCallbackConsoleBase
{
// void PrintPropPair(const char *name, const wchar_t *val);
public:
#ifndef _NO_CRYPTO
bool PasswordIsDefined;
UString Password;
bool AskPassword;
#endif
bool DeleteMessageWasShown;
CUpdateCallbackConsole()
: DeleteMessageWasShown(false)
#ifndef _NO_CRYPTO
, PasswordIsDefined(false)
, AskPassword(false)
#endif
{}
/*
void Init(CStdOutStream *outStream)
{
CCallbackConsoleBase::Init(outStream);
}
*/
// ~CUpdateCallbackConsole() { if (NeedPercents()) _percent.ClosePrint(); }
INTERFACE_IUpdateCallbackUI2(;)
};
#endif
// UpdateCallbackConsole.h
#ifndef __UPDATE_CALLBACK_CONSOLE_H
#define __UPDATE_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
#include "../Common/Update.h"
#include "PercentPrinter.h"
struct CErrorPathCodes
{
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 CCallbackConsoleBase
{
protected:
CPercentPrinter _percent;
CStdOutStream *_so;
CStdOutStream *_se;
void CommonError(const FString &path, DWORD systemError, bool isWarning);
HRESULT ScanError_Base(const FString &path, DWORD systemError);
HRESULT OpenFileError_Base(const FString &name, DWORD systemError);
HRESULT ReadingFileError_Base(const FString &name, DWORD systemError);
public:
bool NeedPercents() const { return _percent._so != NULL; };
bool StdOutMode;
bool NeedFlush;
unsigned PercentsNameLevel;
unsigned LogLevel;
AString _tempA;
UString _tempU;
CCallbackConsoleBase():
StdOutMode(false),
NeedFlush(false),
PercentsNameLevel(1),
LogLevel(0)
{}
void SetWindowWidth(unsigned width) { _percent.MaxLen = width - 1; }
void Init(CStdOutStream *outStream, CStdOutStream *errorStream, CStdOutStream *percentStream)
{
FailedFiles.Clear();
_so = outStream;
_se = errorStream;
_percent._so = percentStream;
}
void ClosePercents2()
{
if (NeedPercents())
_percent.ClosePrint(true);
}
void ClosePercents_for_so()
{
if (NeedPercents() && _so == _percent._so)
_percent.ClosePrint(false);
}
CErrorPathCodes FailedFiles;
CErrorPathCodes ScanErrors;
HRESULT PrintProgress(const wchar_t *name, const char *command, bool showInLog);
};
class CUpdateCallbackConsole: public IUpdateCallbackUI2, public CCallbackConsoleBase
{
// void PrintPropPair(const char *name, const wchar_t *val);
public:
#ifndef _NO_CRYPTO
bool PasswordIsDefined;
UString Password;
bool AskPassword;
#endif
bool DeleteMessageWasShown;
CUpdateCallbackConsole()
: DeleteMessageWasShown(false)
#ifndef _NO_CRYPTO
, PasswordIsDefined(false)
, AskPassword(false)
#endif
{}
/*
void Init(CStdOutStream *outStream)
{
CCallbackConsoleBase::Init(outStream);
}
*/
// ~CUpdateCallbackConsole() { if (NeedPercents()) _percent.ClosePrint(); }
INTERFACE_IUpdateCallbackUI2(;)
};
#endif

View File

@@ -1,110 +1,110 @@
// UserInputUtils.cpp
#include "StdAfx.h"
#include "../../../Common/StdInStream.h"
#include "../../../Common/StringConvert.h"
#include "UserInputUtils.h"
static const char kYes = 'y';
static const char kNo = 'n';
static const char kYesAll = 'a';
static const char kNoAll = 's';
static const char kAutoRenameAll = 'u';
static const char kQuit = 'q';
static const char * const kFirstQuestionMessage = "? ";
static const char * const kHelpQuestionMessage =
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
// return true if pressed Quite;
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
{
if (outStream)
*outStream << kFirstQuestionMessage;
for (;;)
{
if (outStream)
{
*outStream << kHelpQuestionMessage;
outStream->Flush();
}
AString scannedString;
if (!g_StdIn.ScanAStringUntilNewLine(scannedString))
return NUserAnswerMode::kError;
if (g_StdIn.Error())
return NUserAnswerMode::kError;
scannedString.Trim();
if (scannedString.IsEmpty() && g_StdIn.Eof())
return NUserAnswerMode::kEof;
if (scannedString.Len() == 1)
switch (::MyCharLower_Ascii(scannedString[0]))
{
case kYes: return NUserAnswerMode::kYes;
case kNo: return NUserAnswerMode::kNo;
case kYesAll: return NUserAnswerMode::kYesAll;
case kNoAll: return NUserAnswerMode::kNoAll;
case kAutoRenameAll: return NUserAnswerMode::kAutoRenameAll;
case kQuit: return NUserAnswerMode::kQuit;
}
}
}
#ifdef _WIN32
#ifndef UNDER_CE
#define MY_DISABLE_ECHO
#endif
#endif
static bool GetPassword(CStdOutStream *outStream, UString &psw)
{
if (outStream)
{
*outStream << "\nEnter password"
#ifdef MY_DISABLE_ECHO
" (will not be echoed)"
#endif
":";
outStream->Flush();
}
#ifdef MY_DISABLE_ECHO
HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
bool wasChanged = false;
DWORD mode = 0;
if (console != INVALID_HANDLE_VALUE && console != 0)
if (GetConsoleMode(console, &mode))
wasChanged = (SetConsoleMode(console, mode & ~ENABLE_ECHO_INPUT) != 0);
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
if (wasChanged)
SetConsoleMode(console, mode);
#else
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
#endif
if (outStream)
{
*outStream << endl;
outStream->Flush();
}
return res;
}
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw)
{
if (!GetPassword(outStream, psw))
return E_INVALIDARG;
if (g_StdIn.Error())
return E_FAIL;
if (g_StdIn.Eof() && psw.IsEmpty())
return E_ABORT;
return S_OK;
}
// UserInputUtils.cpp
#include "StdAfx.h"
#include "../../../Common/StdInStream.h"
#include "../../../Common/StringConvert.h"
#include "UserInputUtils.h"
static const char kYes = 'y';
static const char kNo = 'n';
static const char kYesAll = 'a';
static const char kNoAll = 's';
static const char kAutoRenameAll = 'u';
static const char kQuit = 'q';
static const char * const kFirstQuestionMessage = "? ";
static const char * const kHelpQuestionMessage =
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
// return true if pressed Quite;
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
{
if (outStream)
*outStream << kFirstQuestionMessage;
for (;;)
{
if (outStream)
{
*outStream << kHelpQuestionMessage;
outStream->Flush();
}
AString scannedString;
if (!g_StdIn.ScanAStringUntilNewLine(scannedString))
return NUserAnswerMode::kError;
if (g_StdIn.Error())
return NUserAnswerMode::kError;
scannedString.Trim();
if (scannedString.IsEmpty() && g_StdIn.Eof())
return NUserAnswerMode::kEof;
if (scannedString.Len() == 1)
switch (::MyCharLower_Ascii(scannedString[0]))
{
case kYes: return NUserAnswerMode::kYes;
case kNo: return NUserAnswerMode::kNo;
case kYesAll: return NUserAnswerMode::kYesAll;
case kNoAll: return NUserAnswerMode::kNoAll;
case kAutoRenameAll: return NUserAnswerMode::kAutoRenameAll;
case kQuit: return NUserAnswerMode::kQuit;
}
}
}
#ifdef _WIN32
#ifndef UNDER_CE
#define MY_DISABLE_ECHO
#endif
#endif
static bool GetPassword(CStdOutStream *outStream, UString &psw)
{
if (outStream)
{
*outStream << "\nEnter password"
#ifdef MY_DISABLE_ECHO
" (will not be echoed)"
#endif
":";
outStream->Flush();
}
#ifdef MY_DISABLE_ECHO
HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
bool wasChanged = false;
DWORD mode = 0;
if (console != INVALID_HANDLE_VALUE && console != 0)
if (GetConsoleMode(console, &mode))
wasChanged = (SetConsoleMode(console, mode & ~ENABLE_ECHO_INPUT) != 0);
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
if (wasChanged)
SetConsoleMode(console, mode);
#else
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
#endif
if (outStream)
{
*outStream << endl;
outStream->Flush();
}
return res;
}
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw)
{
if (!GetPassword(outStream, psw))
return E_INVALIDARG;
if (g_StdIn.Error())
return E_FAIL;
if (g_StdIn.Eof() && psw.IsEmpty())
return E_ABORT;
return S_OK;
}

View File

@@ -1,27 +1,27 @@
// UserInputUtils.h
#ifndef __USER_INPUT_UTILS_H
#define __USER_INPUT_UTILS_H
#include "../../../Common/StdOutStream.h"
namespace NUserAnswerMode {
enum EEnum
{
kYes,
kNo,
kYesAll,
kNoAll,
kAutoRenameAll,
kQuit,
kEof,
kError
};
}
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream);
// bool GetPassword(CStdOutStream *outStream, UString &psw);
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw);
#endif
// UserInputUtils.h
#ifndef __USER_INPUT_UTILS_H
#define __USER_INPUT_UTILS_H
#include "../../../Common/StdOutStream.h"
namespace NUserAnswerMode {
enum EEnum
{
kYes,
kNo,
kYesAll,
kNoAll,
kAutoRenameAll,
kQuit,
kEof,
kError
};
}
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream);
// bool GetPassword(CStdOutStream *outStream, UString &psw);
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw);
#endif

View File

@@ -1,64 +1,64 @@
PROG = 7z.exe
CFLAGS = $(CFLAGS) \
-DEXTERNAL_CODECS \
COMMON_OBJS = \
$O\CommandLineParser.obj \
$O\CRC.obj \
$O\IntToString.obj \
$O\ListFileUtils.obj \
$O\NewHandler.obj \
$O\StdInStream.obj \
$O\StdOutStream.obj \
$O\MyString.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
$O\UTFConvert.obj \
$O\MyVector.obj \
$O\Wildcard.obj \
WIN_OBJS = \
$O\DLL.obj \
$O\ErrorMsg.obj \
$O\FileDir.obj \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileLink.obj \
$O\FileName.obj \
$O\FileSystem.obj \
$O\MemoryLock.obj \
$O\PropVariant.obj \
$O\PropVariantConv.obj \
$O\Registry.obj \
$O\System.obj \
$O\TimeUtils.obj \
7ZIP_COMMON_OBJS = \
$O\CreateCoder.obj \
$O\FilePathAutoRename.obj \
$O\FileStreams.obj \
$O\FilterCoder.obj \
$O\LimitedStreams.obj \
$O\MethodProps.obj \
$O\ProgressUtils.obj \
$O\PropId.obj \
$O\StreamObjects.obj \
$O\StreamUtils.obj \
$O\UniqBlocks.obj \
AR_COMMON_OBJS = \
$O\OutStreamWithCRC.obj \
COMPRESS_OBJS = \
$O\CopyCoder.obj \
C_OBJS = $(C_OBJS) \
$O\Alloc.obj \
$O\CpuArch.obj \
$O\Sort.obj \
$O\Threads.obj \
!include "../../Crc.mak"
!include "Console.mak"
!include "../../7zip.mak"
PROG = 7z.exe
CFLAGS = $(CFLAGS) \
-DEXTERNAL_CODECS \
COMMON_OBJS = \
$O\CommandLineParser.obj \
$O\CRC.obj \
$O\IntToString.obj \
$O\ListFileUtils.obj \
$O\NewHandler.obj \
$O\StdInStream.obj \
$O\StdOutStream.obj \
$O\MyString.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
$O\UTFConvert.obj \
$O\MyVector.obj \
$O\Wildcard.obj \
WIN_OBJS = \
$O\DLL.obj \
$O\ErrorMsg.obj \
$O\FileDir.obj \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileLink.obj \
$O\FileName.obj \
$O\FileSystem.obj \
$O\MemoryLock.obj \
$O\PropVariant.obj \
$O\PropVariantConv.obj \
$O\Registry.obj \
$O\System.obj \
$O\TimeUtils.obj \
7ZIP_COMMON_OBJS = \
$O\CreateCoder.obj \
$O\FilePathAutoRename.obj \
$O\FileStreams.obj \
$O\FilterCoder.obj \
$O\LimitedStreams.obj \
$O\MethodProps.obj \
$O\ProgressUtils.obj \
$O\PropId.obj \
$O\StreamObjects.obj \
$O\StreamUtils.obj \
$O\UniqBlocks.obj \
AR_COMMON_OBJS = \
$O\OutStreamWithCRC.obj \
COMPRESS_OBJS = \
$O\CopyCoder.obj \
C_OBJS = $(C_OBJS) \
$O\Alloc.obj \
$O\CpuArch.obj \
$O\Sort.obj \
$O\Threads.obj \
!include "../../Crc.mak"
!include "Console.mak"
!include "../../7zip.mak"

View File

@@ -1,7 +1,7 @@
#include "../../MyVersionInfo.rc"
MY_VERSION_INFO_APP("7-Zip Console" , "7z")
#ifndef UNDER_CE
1 24 MOVEABLE PURE "Console.manifest"
#endif
#include "../../MyVersionInfo.rc"
MY_VERSION_INFO_APP("7-Zip Console" , "7z")
#ifndef UNDER_CE
1 24 MOVEABLE PURE "Console.manifest"
#endif