This commit is contained in:
Igor Pavlov
2014-11-23 00:00:00 +00:00
committed by Kornel Lesiński
parent 83f8ddcc5b
commit f08f4dcc3c
1158 changed files with 76451 additions and 35082 deletions

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

@@ -32,7 +32,7 @@ HRESULT CPrintBenchCallback::CheckBreak()
}
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> props, UInt32 numIterations, FILE *f)
const CObjectVector<CProperty> &props, UInt32 numIterations, FILE *f)
{
CPrintBenchCallback callback;
callback._file = f;

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

@@ -9,6 +9,6 @@
#include "../../UI/Common/Property.h"
HRESULT BenchCon(DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> props, UInt32 numIterations, FILE *f);
const CObjectVector<CProperty> &props, UInt32 numIterations, FILE *f);
#endif

157
CPP/7zip/UI/Console/Console.dsp Executable file → Normal file
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 /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /FAs /Yu"StdAfx.h" /FD /c
# ADD CPP /nologo /Gz /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" /FAs /Yu"StdAfx.h" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -52,7 +52,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"C:\UTIL\7z.exe" /OPT:NOWIN98
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"C:\UTIL\7z.exe" /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "Console - Win32 Debug"
@@ -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 /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /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 /Gz /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 BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -77,7 +77,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"C:\UTIL\7z.exe" /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"C:\UTIL\7z.exe" /pdbtype:sept
!ELSEIF "$(CFG)" == "Console - Win32 ReleaseU"
@@ -94,7 +94,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 /Gz /MD /W3 /GX /O1 /I "../../../" /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 /Gz /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 BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
@@ -102,7 +102,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"C:\UTIL\7z.exe"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"C:\UTIL\7zn.exe" /OPT:NOWIN98
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"C:\UTIL\7zn.exe" /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "Console - Win32 DebugU"
@@ -120,7 +120,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 /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /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 /Gz /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 BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
@@ -128,7 +128,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"C:\UTIL\7z.exe" /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"C:\UTIL\7z.exe" /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"C:\UTIL\7z.exe" /pdbtype:sept
!ENDIF
@@ -184,6 +184,14 @@ SOURCE=.\ExtractCallbackConsole.h
# End Source File
# Begin Source File
SOURCE=.\HashCon.cpp
# End Source File
# Begin Source File
SOURCE=.\HashCon.h
# End Source File
# Begin Source File
SOURCE=.\List.cpp
# End Source File
# Begin Source File
@@ -244,11 +252,11 @@ SOURCE=..\..\..\Windows\DLL.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Error.cpp
SOURCE=..\..\..\Windows\ErrorMsg.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Error.h
SOURCE=..\..\..\Windows\ErrorMsg.h
# End Source File
# Begin Source File
@@ -276,6 +284,14 @@ SOURCE=..\..\..\Windows\FileIO.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\FileLink.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\FileMapping.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\FileName.cpp
# End Source File
# Begin Source File
@@ -284,6 +300,14 @@ SOURCE=..\..\..\Windows\FileName.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\FileSystem.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\FileSystem.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\MemoryLock.cpp
# End Source File
# Begin Source File
@@ -304,11 +328,11 @@ SOURCE=..\..\..\Windows\PropVariant.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\PropVariantConversions.cpp
SOURCE=..\..\..\Windows\PropVariantConv.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\PropVariantConversions.h
SOURCE=..\..\..\Windows\PropVariantConv.h
# End Source File
# Begin Source File
@@ -320,6 +344,10 @@ SOURCE=..\..\..\Windows\Registry.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Synchronization.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\System.cpp
# End Source File
# Begin Source File
@@ -328,11 +356,15 @@ SOURCE=..\..\..\Windows\System.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Time.cpp
SOURCE=..\..\..\Windows\Thread.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Time.h
SOURCE=..\..\..\Windows\TimeUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\TimeUtils.h
# End Source File
# End Group
# Begin Group "Common"
@@ -340,10 +372,6 @@ SOURCE=..\..\..\Windows\Time.h
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\Buffer.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\CommandLineParser.cpp
# End Source File
# Begin Source File
@@ -380,6 +408,10 @@ SOURCE=..\..\..\Common\ListFileUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyBuffer.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyCom.h
# End Source File
# Begin Source File
@@ -392,6 +424,10 @@ SOURCE=..\..\..\Common\MyString.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyTypes.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\MyVector.cpp
# End Source File
# Begin Source File
@@ -532,6 +568,18 @@ SOURCE=..\Common\ExtractingFilePath.h
# End Source File
# Begin Source File
SOURCE=..\Common\ExtractMode.h
# End Source File
# Begin Source File
SOURCE=..\Common\HashCalc.cpp
# End Source File
# Begin Source File
SOURCE=..\Common\HashCalc.h
# End Source File
# Begin Source File
SOURCE=..\Common\IFileExtractCallback.h
# End Source File
# Begin Source File
@@ -668,6 +716,14 @@ SOURCE=..\..\Common\FilterCoder.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\LimitedStreams.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\LimitedStreams.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\MethodProps.cpp
# End Source File
# Begin Source File
@@ -684,16 +740,36 @@ SOURCE=..\..\Common\ProgressUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\PropId.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\RegisterArc.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamObjects.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamObjects.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\UniqBlocks.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\UniqBlocks.h
# End Source File
# End Group
# Begin Group "Compress"
@@ -740,6 +816,10 @@ SOURCE=..\..\..\..\C\7zCrc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\7zTypes.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -758,6 +838,15 @@ SOURCE=..\..\..\..\C\CpuArch.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Sort.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Sort.h
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Threads.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
@@ -839,6 +928,38 @@ InputName=7zCrcOpt
!ENDIF
# End Source File
# End Group
# Begin Group "Interface"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Archive\IArchive.h
# End Source File
# Begin Source File
SOURCE=..\..\ICoder.h
# End Source File
# Begin Source File
SOURCE=..\..\IDecl.h
# End Source File
# Begin Source File
SOURCE=..\..\IPassword.h
# End Source File
# Begin Source File
SOURCE=..\..\IProgress.h
# End Source File
# Begin Source File
SOURCE=..\..\IStream.h
# End Source File
# Begin Source File
SOURCE=..\..\PropID.h
# End Source File
# End Group
# End Target

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

View File

@@ -0,0 +1,35 @@
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 \

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

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

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

@@ -1,20 +1,21 @@
// ExtractCallbackConsole.h
// ExtractCallbackConsole.cpp
#include "StdAfx.h"
// #undef sprintf
#include "ConsoleClose.h"
#include "ExtractCallbackConsole.h"
#include "UserInputUtils.h"
#include "ConsoleClose.h"
#include "Common/Wildcard.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/Wildcard.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "Windows/Time.h"
#include "Windows/Defs.h"
#include "Windows/PropVariant.h"
#include "Windows/Error.h"
#include "Windows/PropVariantConversions.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileFind.h"
#include "../../../Windows/TimeUtils.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/PropVariantConv.h"
#include "../../Common/FilePathAutoRename.h"
@@ -22,11 +23,11 @@
using namespace NWindows;
using namespace NFile;
using namespace NDirectory;
using namespace NDir;
static const char *kTestString = "Testing ";
static const char *kExtractString = "Extracting ";
static const char *kSkipString = "Skipping ";
static const char *kSkipString = "Skipping ";
// static const char *kCantAutoRename = "can not create file with auto name\n";
// static const char *kCantRenameFile = "can not rename existing file\n";
@@ -43,7 +44,27 @@ static const char *kCrcFailed = "CRC Failed";
static const char *kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
static const char *kDataError = "Data Error";
static const char *kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
static const char *kUnknownError = "Unknown Error";
static const char *kUnavailableData = "Unavailable data";
static const char *kUnexpectedEnd = "Unexpected end of data";
static const char *kDataAfterEnd = "There are some data after the end of the payload data";
static const char *kIsNotArc = "Is not archive";
static const char *kHeadersError = "Headers Error";
static const char *k_ErrorFlagsMessages[] =
{
"Is not archive"
, "Headers Error"
, "Headers Error in encrypted archive. Wrong password?"
, "Unavailable start of archive"
, "Unconfirmed start of archive"
, "Unexpected end of archive"
, "There are data after the end of archive"
, "Unsupported method"
, "Unsupported feature"
, "Data Error"
, "CRC Error"
};
STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64)
{
@@ -64,13 +85,13 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
const wchar_t *newName, const FILETIME *, const UInt64 *,
Int32 *answer)
{
(*OutStream) << "file " << existName <<
"\nalready exists. Overwrite with " << endl;
(*OutStream) << newName;
(*OutStream) << "file " << existName << endl <<
"already exists. Overwrite with" << endl <<
newName;
NUserAnswerMode::EEnum overwriteAnswer = ScanUserYesNoAllQuit(OutStream);
switch(overwriteAnswer)
switch (overwriteAnswer)
{
case NUserAnswerMode::kQuit: return E_ABORT;
case NUserAnswerMode::kNo: *answer = NOverwriteAnswer::kNo; break;
@@ -85,13 +106,15 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, bool /* isFolder */, Int32 askExtractMode, const UInt64 *position)
{
const char *s;
switch (askExtractMode)
{
case NArchive::NExtract::NAskMode::kExtract: (*OutStream) << kExtractString; break;
case NArchive::NExtract::NAskMode::kTest: (*OutStream) << kTestString; break;
case NArchive::NExtract::NAskMode::kSkip: (*OutStream) << kSkipString; break;
case NArchive::NExtract::NAskMode::kExtract: s = kExtractString; break;
case NArchive::NExtract::NAskMode::kTest: s = kTestString; break;
case NArchive::NExtract::NAskMode::kSkip: s = kSkipString; break;
default: s = ""; // return E_FAIL;
};
(*OutStream) << name;
(*OutStream) << s << name;
if (position != 0)
(*OutStream) << " <" << *position << ">";
return S_OK;
@@ -100,35 +123,57 @@ STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, bool
STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
{
(*OutStream) << message << endl;
NumFileErrorsInCurrentArchive++;
NumFileErrorsInCurrent++;
NumFileErrors++;
return S_OK;
}
STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 operationResult, bool encrypted)
{
switch(operationResult)
switch (operationResult)
{
case NArchive::NExtract::NOperationResult::kOK:
break;
default:
{
NumFileErrorsInCurrentArchive++;
NumFileErrorsInCurrent++;
NumFileErrors++;
(*OutStream) << " ";
switch(operationResult)
(*OutStream) << " : ";
const char *s = NULL;
switch (operationResult)
{
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
(*OutStream) << kUnsupportedMethod;
case NArchive::NExtract::NOperationResult::kUnsupportedMethod:
s = kUnsupportedMethod;
break;
case NArchive::NExtract::NOperationResult::kCRCError:
(*OutStream) << (encrypted ? kCrcFailedEncrypted: kCrcFailed);
s = (encrypted ? kCrcFailedEncrypted : kCrcFailed);
break;
case NArchive::NExtract::NOperationResult::kDataError:
(*OutStream) << (encrypted ? kDataErrorEncrypted : kDataError);
s = (encrypted ? kDataErrorEncrypted : kDataError);
break;
default:
(*OutStream) << kUnknownError;
case NArchive::NExtract::NOperationResult::kUnavailable:
s = kUnavailableData;
break;
case NArchive::NExtract::NOperationResult::kUnexpectedEnd:
s = kUnexpectedEnd;
break;
case NArchive::NExtract::NOperationResult::kDataAfterEnd:
s = kDataAfterEnd;
break;
case NArchive::NExtract::NOperationResult::kIsNotArc:
s = kIsNotArc;
break;
case NArchive::NExtract::NOperationResult::kHeadersError:
s = kHeadersError;
break;
}
if (s)
(*OutStream) << "Error : " << s;
else
{
char temp[16];
ConvertUInt32ToString(operationResult, temp);
(*OutStream) << "Error #" << temp;
}
}
}
@@ -159,8 +204,10 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name)
{
NumArchives++;
NumFileErrorsInCurrentArchive = 0;
NumTryArcs++;
ThereIsErrorInCurrent = false;
ThereIsWarningInCurrent = false;
NumFileErrorsInCurrent = 0;
(*OutStream) << endl << kProcessing << name << endl;
return S_OK;
}
@@ -182,13 +229,95 @@ HRESULT CExtractCallbackConsole::OpenResult(const wchar_t * /* name */, HRESULT
if (result == E_OUTOFMEMORY)
(*OutStream) << "Can't allocate required memory";
else
(*OutStream) << NError::MyFormatMessageW(result);
(*OutStream) << NError::MyFormatMessage(result);
}
(*OutStream) << endl;
NumArchiveErrors++;
NumCantOpenArcs++;
ThereIsErrorInCurrent = true;
}
return S_OK;
}
AString GetOpenArcErrorMessage(UInt32 errorFlags)
{
AString s;
for (unsigned i = 0; i < ARRAY_SIZE(k_ErrorFlagsMessages); i++)
{
UInt32 f = (1 << i);
if ((errorFlags & f) == 0)
continue;
const char *m = k_ErrorFlagsMessages[i];
if (!s.IsEmpty())
s += '\n';
s += m;
errorFlags &= ~f;
}
if (errorFlags != 0)
{
char sz[16];
sz[0] = '0';
sz[1] = 'x';
ConvertUInt32ToHex(errorFlags, sz + 2);
if (!s.IsEmpty())
s += '\n';
s += sz;
}
return s;
}
HRESULT CExtractCallbackConsole::SetError(int level, const wchar_t *name,
UInt32 errorFlags, const wchar_t *errors,
UInt32 warningFlags, const wchar_t *warnings)
{
if (level != 0)
{
(*OutStream) << name << endl;
}
if (errorFlags != 0)
{
(*OutStream) << "Errors: ";
(*OutStream) << endl;
(*OutStream) << GetOpenArcErrorMessage(errorFlags);
(*OutStream) << endl;
NumOpenArcErrors++;
ThereIsErrorInCurrent = true;
}
if (errors && wcslen(errors) != 0)
{
(*OutStream) << "Errors: ";
(*OutStream) << endl;
(*OutStream) << errors;
(*OutStream) << endl;
NumOpenArcErrors++;
ThereIsErrorInCurrent = true;
}
if (warningFlags != 0)
{
(*OutStream) << "Warnings: ";
(*OutStream) << endl;
(*OutStream) << GetOpenArcErrorMessage(warningFlags);
(*OutStream) << endl;
NumOpenArcWarnings++;
ThereIsWarningInCurrent = true;
}
if (warnings && wcslen(warnings) != 0)
{
(*OutStream) << "Warnings: ";
(*OutStream) << endl;
(*OutStream) << warnings;
(*OutStream) << endl;
NumOpenArcWarnings++;
ThereIsWarningInCurrent = true;
}
(*OutStream) << endl;
return S_OK;
}
HRESULT CExtractCallbackConsole::ThereAreNoFiles()
{
@@ -201,24 +330,54 @@ HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
if (result == S_OK)
{
(*OutStream) << endl;
if (NumFileErrorsInCurrentArchive == 0)
if (NumFileErrorsInCurrent == 0 && !ThereIsErrorInCurrent)
{
if (ThereIsWarningInCurrent)
NumArcsWithWarnings++;
else
NumOkArcs++;
(*OutStream) << kEverythingIsOk << endl;
}
else
{
NumArchiveErrors++;
(*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrentArchive << endl;
NumArcsWithError++;
if (NumFileErrorsInCurrent != 0)
(*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrent << endl;
}
return S_OK;
}
if (result == S_OK)
return result;
NumArchiveErrors++;
NumArcsWithError++;
if (result == E_ABORT || result == ERROR_DISK_FULL)
return result;
(*OutStream) << endl << kError;
if (result == E_OUTOFMEMORY)
(*OutStream) << kMemoryExceptionMessage;
else
(*OutStream) << NError::MyFormatMessageW(result);
(*OutStream) << NError::MyFormatMessage(result);
(*OutStream) << endl;
return S_OK;
}
HRESULT CExtractCallbackConsole::OpenTypeWarning(const wchar_t *name, const wchar_t *okType, const wchar_t *errorType)
{
UString s = L"Warning:\n";
if (wcscmp(okType, errorType) == 0)
{
s += L"The archive is open with offset";
}
else
{
s += name;
s += L"\nCan not open the file as [";
s += errorType;
s += L"] archive\n";
s += L"The file is open as [";
s += okType;
s += L"] archive";
}
(*OutStream) << s << endl << endl;
ThereIsWarningInCurrent = true;
return S_OK;
}

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

@@ -3,11 +3,15 @@
#ifndef __EXTRACTCALLBACKCONSOLE_H
#define __EXTRACTCALLBACKCONSOLE_H
#include "Common/MyString.h"
#include "Common/StdOutStream.h"
#include "../../../Common/MyString.h"
#include "../../../Common/StdOutStream.h"
#include "../../Common/FileStreams.h"
#include "../../IPassword.h"
#include "../../Archive/IArchive.h"
#include "../Common/ArchiveExtractCallback.h"
class CExtractCallbackConsole:
@@ -40,8 +44,13 @@ public:
HRESULT BeforeOpen(const wchar_t *name);
HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted);
HRESULT SetError(int level, const wchar_t *name,
UInt32 errorFlags, const wchar_t *errors,
UInt32 warningFlags, const wchar_t *warnings);
HRESULT ThereAreNoFiles();
HRESULT ExtractResult(HRESULT result);
HRESULT OpenTypeWarning(const wchar_t *name, const wchar_t *okType, const wchar_t *errorType);
#ifndef _NO_CRYPTO
@@ -53,19 +62,36 @@ public:
#endif
UInt64 NumArchives;
UInt64 NumArchiveErrors;
UInt64 NumTryArcs;
bool ThereIsErrorInCurrent;
bool ThereIsWarningInCurrent;
UInt64 NumCantOpenArcs;
UInt64 NumOkArcs;
UInt64 NumArcsWithError;
UInt64 NumArcsWithWarnings;
UInt64 NumProblemArcsLevs;
UInt64 NumOpenArcErrors;
UInt64 NumOpenArcWarnings;
UInt64 NumFileErrors;
UInt64 NumFileErrorsInCurrentArchive;
UInt64 NumFileErrorsInCurrent;
CStdOutStream *OutStream;
void Init()
{
NumArchives = 0;
NumArchiveErrors = 0;
NumTryArcs = 0;
NumOkArcs = 0;
NumCantOpenArcs = 0;
NumArcsWithError = 0;
NumArcsWithWarnings = 0;
NumOpenArcErrors = 0;
NumOpenArcWarnings = 0;
NumFileErrors = 0;
NumFileErrorsInCurrentArchive = 0;
NumFileErrorsInCurrent = 0;
}
};

View File

@@ -0,0 +1,274 @@
// HashCon.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
#include "../../../Windows/ErrorMsg.h"
#include "ConsoleClose.h"
#include "HashCon.h"
static const wchar_t *kEmptyFileAlias = L"[Content]";
static const char *kScanningMessage = "Scanning";
HRESULT CHashCallbackConsole::CheckBreak()
{
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
}
HRESULT CHashCallbackConsole::StartScanning()
{
(*OutStream) << kScanningMessage;
return CheckBreak();
}
HRESULT CHashCallbackConsole::ScanProgress(UInt64 /* numFolders */, UInt64 /* numFiles */, UInt64 /* totalSize */, const wchar_t * /* path */, bool /* isDir */)
{
return CheckBreak();
}
HRESULT CHashCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
{
return CanNotFindError_Base(name, systemError);
}
HRESULT CHashCallbackConsole::FinishScanning()
{
(*OutStream) << endl << endl;
return CheckBreak();
}
HRESULT CHashCallbackConsole::SetNumFiles(UInt64 /* numFiles */)
{
return CheckBreak();
}
HRESULT CHashCallbackConsole::SetTotal(UInt64 size)
{
if (EnablePercents)
m_PercentPrinter.SetTotal(size);
return CheckBreak();
}
HRESULT CHashCallbackConsole::SetCompleted(const UInt64 *completeValue)
{
if (completeValue && EnablePercents)
{
m_PercentPrinter.SetRatio(*completeValue);
m_PercentPrinter.PrintRatio();
}
return CheckBreak();
}
static void AddMinuses(AString &s, unsigned num)
{
for (unsigned i = 0; i < num; i++)
s += '-';
}
static void SetSpaces(char *s, int num)
{
for (int i = 0; i < num; i++)
s[i] = ' ';
}
static void SetSpacesAndNul(char *s, int num)
{
SetSpaces(s, num);
s[num] = 0;
}
static void AddSpaces(UString &s, int num)
{
for (int i = 0; i < num; i++)
s += ' ';
}
static const int kSizeField_Len = 13;
static const int kNameField_Len = 12;
static unsigned GetColumnWidth(unsigned digestSize)
{
unsigned width = digestSize * 2;
const unsigned kMinColumnWidth = 8;
return width < kMinColumnWidth ? kMinColumnWidth: width;
}
void CHashCallbackConsole::PrintSeparatorLine(const CObjectVector<CHasherState> &hashers)
{
AString s;
for (unsigned i = 0; i < hashers.Size(); i++)
{
const CHasherState &h = hashers[i];
AddMinuses(s, GetColumnWidth(h.DigestSize));
s += ' ';
}
AddMinuses(s, kSizeField_Len);
s += " ";
AddMinuses(s, kNameField_Len);
m_PercentPrinter.PrintString(s);
m_PercentPrinter.PrintNewLine();
}
HRESULT CHashCallbackConsole::BeforeFirstFile(const CHashBundle &hb)
{
UString s;
FOR_VECTOR (i, hb.Hashers)
{
const CHasherState &h = hb.Hashers[i];
s += h.Name;
AddSpaces(s, (int)GetColumnWidth(h.DigestSize) - h.Name.Len() + 1);
}
UString s2 = L"Size";
AddSpaces(s, kSizeField_Len - s2.Len());
s += s2;
s += L" ";
s += L"Name";
m_PercentPrinter.PrintString(s);
m_PercentPrinter.PrintNewLine();
PrintSeparatorLine(hb.Hashers);
return CheckBreak();
}
HRESULT CHashCallbackConsole::OpenFileError(const wchar_t *name, DWORD systemError)
{
FailedCodes.Add(systemError);
FailedFiles.Add(name);
// if (systemError == ERROR_SHARING_VIOLATION)
{
m_PercentPrinter.PrintString(name);
m_PercentPrinter.PrintString(": WARNING: ");
m_PercentPrinter.PrintString(NWindows::NError::MyFormatMessage(systemError));
return S_FALSE;
}
// return systemError;
}
HRESULT CHashCallbackConsole::GetStream(const wchar_t *name, bool /* isFolder */)
{
m_FileName = name;
return CheckBreak();
}
void CHashCallbackConsole::PrintResultLine(UInt64 fileSize,
const CObjectVector<CHasherState> &hashers, unsigned digestIndex, bool showHash)
{
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) + 1);
m_PercentPrinter.PrintString(s);
}
char s[64];
s[0] = 0;
char *p = s;
if (showHash && fileSize != 0)
{
p = s + 32;
ConvertUInt64ToString(fileSize, p);
int numSpaces = kSizeField_Len - (int)strlen(p);
if (numSpaces > 0)
{
p -= numSpaces;
SetSpaces(p, numSpaces);
}
}
else
SetSpacesAndNul(s, kSizeField_Len - (int)strlen(s));
unsigned len = (unsigned)strlen(p);
p[len] = ' ';
p[len + 1] = ' ';
p[len + 2] = 0;
m_PercentPrinter.PrintString(p);
}
HRESULT CHashCallbackConsole::SetOperationResult(UInt64 fileSize, const CHashBundle &hb, bool showHash)
{
PrintResultLine(fileSize, hb.Hashers, k_HashCalc_Index_Current, showHash);
if (m_FileName.IsEmpty())
m_PercentPrinter.PrintString(kEmptyFileAlias);
else
m_PercentPrinter.PrintString(m_FileName);
m_PercentPrinter.PrintNewLine();
return S_OK;
}
static const char *k_DigestTitles[] =
{
" :"
, " for data: "
, " for data and names: "
, " for streams and names: "
};
static void PrintSum(CStdOutStream &p, const CHasherState &h, unsigned digestIndex)
{
char s[k_HashCalc_DigestSize_Max * 2 + 64];
UString name = h.Name;
AddSpaces(name, 6 - (int)name.Len());
p << name;
p << k_DigestTitles[digestIndex];
s[0] = 0;
AddHashHexToString(s, h.Digests[digestIndex], h.DigestSize);
p << s;
p << "\n";
}
void PrintHashStat(CStdOutStream &p, const CHashBundle &hb)
{
FOR_VECTOR (i, hb.Hashers)
{
const CHasherState &h = hb.Hashers[i];
p << "\n";
PrintSum(p, h, k_HashCalc_Index_DataSum);
if (hb.NumFiles != 1 || hb.NumDirs != 0)
PrintSum(p, h, k_HashCalc_Index_NamesSum);
if (hb.NumAltStreams != 0)
PrintSum(p, h, k_HashCalc_Index_StreamsSum);
}
}
void CHashCallbackConsole::PrintProperty(const char *name, UInt64 value)
{
char s[32];
s[0] = ':';
s[1] = ' ';
ConvertUInt64ToString(value, s + 2);
m_PercentPrinter.PrintString(name);
m_PercentPrinter.PrintString(s);
m_PercentPrinter.PrintNewLine();
}
HRESULT CHashCallbackConsole::AfterLastFile(const CHashBundle &hb)
{
PrintSeparatorLine(hb.Hashers);
PrintResultLine(hb.FilesSize, hb.Hashers, k_HashCalc_Index_DataSum, true);
m_PercentPrinter.PrintNewLine();
m_PercentPrinter.PrintNewLine();
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("AltStreams", hb.NumAltStreams);
PrintProperty("AltStreams size", hb.AltStreamsSize);
}
PrintHashStat(*m_PercentPrinter.OutStream, hb);
m_PercentPrinter.PrintNewLine();
return S_OK;
}

View File

@@ -0,0 +1,26 @@
// HashCon.h
#ifndef __HASH_CON_H
#define __HASH_CON_H
#include "../Common/HashCalc.h"
#include "UpdateCallbackConsole.h"
class CHashCallbackConsole: public IHashCallbackUI, public CCallbackConsoleBase
{
UString m_FileName;
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:
~CHashCallbackConsole() { }
INTERFACE_IHashCallbackUI(;)
};
void PrintHashStat(CStdOutStream &stdStream, const CHashBundle &hb);
#endif

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

File diff suppressed because it is too large Load Diff

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

@@ -3,18 +3,25 @@
#ifndef __LIST_H
#define __LIST_H
#include "Common/Wildcard.h"
#include "../../../Common/Wildcard.h"
#include "../Common/LoadCodecs.h"
HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
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
UInt64 &errors);
#ifndef _SFX
const CObjectVector<CProperty> *props,
#endif
UInt64 &errors,
UInt64 &numWarnings);
#endif

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

File diff suppressed because it is too large Load Diff

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

@@ -2,11 +2,11 @@
#include "StdAfx.h"
#include "Common/MyException.h"
#include "Common/StdOutStream.h"
#include "../../../Common/MyException.h"
#include "../../../Common/StdOutStream.h"
#include "Windows/Error.h"
#include "Windows/NtCheck.h"
#include "../../../Windows/ErrorMsg.h"
#include "../../../Windows/NtCheck.h"
#include "../Common/ArchiveCommandLine.h"
#include "../Common/ExitCode.h"
@@ -23,6 +23,7 @@ extern int Main2(
#endif
);
static const char *kException_CmdLine_Error_Message = "\n\nCommand Line Error:\n";
static const char *kExceptionErrorMessage = "\n\nError:\n";
static const char *kUserBreak = "\nBreak signaled\n";
static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
@@ -62,9 +63,9 @@ int MY_CDECL main
(*g_StdStream) << endl << kUserBreak;
return (NExitCode::kUserBreak);
}
catch(const CArchiveCommandLineException &e)
catch(const CArcCmdLineException &e)
{
(*g_StdStream) << kExceptionErrorMessage << e << endl;
(*g_StdStream) << kException_CmdLine_Error_Message << e << endl;
return (NExitCode::kUserError);
}
catch(const CSystemException &systemError)
@@ -80,7 +81,7 @@ int MY_CDECL main
return (NExitCode::kUserBreak);
}
(*g_StdStream) << endl << endl << "System error:" << endl <<
NError::MyFormatMessageW(systemError.ErrorCode) << endl;
NError::MyFormatMessage(systemError.ErrorCode) << endl;
return (NExitCode::kFatalError);
}
catch(NExitCode::EEnum &exitCode)
@@ -120,5 +121,5 @@ int MY_CDECL main
(*g_StdStream) << kUnknownExceptionMessage;
return (NExitCode::kFatalError);
}
return res;
return res;
}

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

@@ -38,10 +38,10 @@ HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
return StringToBstr(Password, password);
}
HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(UString &password)
HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password)
{
if (PasswordIsDefined)
password = Password;
passwordIsDefined = PasswordIsDefined;
password = Password;
return S_OK;
}

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

@@ -1,9 +1,10 @@
// OpenCallbackConsole.h
#ifndef __OPENCALLBACKCONSOLE_H
#define __OPENCALLBACKCONSOLE_H
#ifndef __OPEN_CALLBACK_CONSOLE_H
#define __OPEN_CALLBACK_CONSOLE_H
#include "../../../Common/StdOutStream.h"
#include "Common/StdOutStream.h"
#include "../Common/ArchiveOpenCallback.h"
class COpenCallbackConsole: public IOpenCallbackUI

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

@@ -2,8 +2,8 @@
#include "StdAfx.h"
#include "Common/IntToString.h"
#include "Common/MyString.h"
#include "../../../Common/Defs.h"
#include "../../../Common/IntToString.h"
#include "PercentPrinter.h"

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

@@ -3,7 +3,7 @@
#ifndef __PERCENT_PRINTER_H
#define __PERCENT_PRINTER_H
#include "Common/StdOutStream.h"
#include "../../../Common/StdOutStream.h"
class CPercentPrinter
{

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

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

@@ -3,7 +3,6 @@
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#include "../../../Common/NewHandler.h"
#include "../../../Common/Common.h"
#endif

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

@@ -2,15 +2,14 @@
#include "StdAfx.h"
#include "UpdateCallbackConsole.h"
#include "Windows/Error.h"
#include "../../../Windows/ErrorMsg.h"
#ifndef _7ZIP_ST
#include "Windows/Synchronization.h"
#include "../../../Windows/Synchronization.h"
#endif
#include "ConsoleClose.h"
#include "UserInputUtils.h"
#include "UpdateCallbackConsole.h"
using namespace NWindows;
@@ -28,11 +27,18 @@ static const char *kUpdatingArchiveMessage = "Updating archive ";
static const char *kScanningMessage = "Scanning";
HRESULT CUpdateCallbackConsole::OpenResult(const wchar_t *name, HRESULT result)
HRESULT CUpdateCallbackConsole::OpenResult(const wchar_t *name, HRESULT result, const wchar_t *errorArcType)
{
(*OutStream) << endl;
if (result != S_OK)
(*OutStream) << "Error: " << name << " is not supported archive" << endl;
{
(*OutStream) << "Error: " << name;
if (errorArcType)
(*OutStream) << " : can not open the file as [" << errorArcType << "] archive";
else
(*OutStream) << " is not supported archive";
(*OutStream) << endl;
}
return S_OK;
}
@@ -42,12 +48,12 @@ HRESULT CUpdateCallbackConsole::StartScanning()
return S_OK;
}
HRESULT CUpdateCallbackConsole::ScanProgress(UInt64 /* numFolders */, UInt64 /* numFiles */, const wchar_t * /* path */)
HRESULT CUpdateCallbackConsole::ScanProgress(UInt64 /* numFolders */, UInt64 /* numFiles */, UInt64 /* totalSize */, const wchar_t * /* path */, bool /* isDir */)
{
return CheckBreak();
}
HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
HRESULT CCallbackConsoleBase::CanNotFindError_Base(const wchar_t *name, DWORD systemError)
{
CantFindFiles.Add(name);
CantFindCodes.Add(systemError);
@@ -60,11 +66,16 @@ HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD syste
}
m_PercentPrinter.PrintString(name);
m_PercentPrinter.PrintString(": WARNING: ");
m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
m_PercentPrinter.PrintString(NError::MyFormatMessage(systemError));
m_PercentPrinter.PrintNewLine();
return S_OK;
}
HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
{
return CanNotFindError_Base(name, systemError);
}
HRESULT CUpdateCallbackConsole::FinishScanning()
{
(*OutStream) << endl << endl;
@@ -176,15 +187,19 @@ HRESULT CUpdateCallbackConsole::OpenFileError(const wchar_t *name, DWORD systemE
MT_LOCK
FailedCodes.Add(systemError);
FailedFiles.Add(name);
// if (systemError == ERROR_SHARING_VIOLATION)
/*
if (systemError == ERROR_SHARING_VIOLATION)
{
*/
m_PercentPrinter.ClosePrint();
m_PercentPrinter.PrintNewLine();
m_PercentPrinter.PrintString("WARNING: ");
m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
m_PercentPrinter.PrintString(NError::MyFormatMessage(systemError));
return S_FALSE;
/*
}
// return systemError;
return systemError;
*/
}
HRESULT CUpdateCallbackConsole::SetOperationResult(Int32 )

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

@@ -3,55 +3,39 @@
#ifndef __UPDATE_CALLBACK_CONSOLE_H
#define __UPDATE_CALLBACK_CONSOLE_H
#include "Common/StdOutStream.h"
#include "../../../Common/StdOutStream.h"
#include "../Common/Update.h"
#include "PercentPrinter.h"
class CUpdateCallbackConsole: public IUpdateCallbackUI2
class CCallbackConsoleBase
{
CPercentPrinter m_PercentPrinter;
bool m_NeedBeClosed;
bool m_NeedNewLine;
bool m_WarningsMode;
protected:
CPercentPrinter m_PercentPrinter;
CStdOutStream *OutStream;
HRESULT CanNotFindError_Base(const wchar_t *name, DWORD systemError);
public:
bool EnablePercents;
bool StdOutMode;
#ifndef _NO_CRYPTO
bool PasswordIsDefined;
UString Password;
bool AskPassword;
#endif
CUpdateCallbackConsole():
CCallbackConsoleBase():
m_PercentPrinter(1 << 16),
#ifndef _NO_CRYPTO
PasswordIsDefined(false),
AskPassword(false),
#endif
StdOutMode(false),
EnablePercents(true),
m_WarningsMode(false)
{}
~CUpdateCallbackConsole() { Finilize(); }
void Init(CStdOutStream *outStream)
{
m_NeedBeClosed = false;
m_NeedNewLine = false;
FailedFiles.Clear();
FailedCodes.Clear();
OutStream = outStream;
m_PercentPrinter.OutStream = outStream;
}
INTERFACE_IUpdateCallbackUI2(;)
UStringVector FailedFiles;
CRecordVector<HRESULT> FailedCodes;
@@ -59,4 +43,33 @@ public:
CRecordVector<HRESULT> CantFindCodes;
};
class CUpdateCallbackConsole: public IUpdateCallbackUI2, public CCallbackConsoleBase
{
bool m_NeedBeClosed;
bool m_NeedNewLine;
public:
#ifndef _NO_CRYPTO
bool PasswordIsDefined;
UString Password;
bool AskPassword;
#endif
CUpdateCallbackConsole()
#ifndef _NO_CRYPTO
:
PasswordIsDefined(false),
AskPassword(false)
#endif
{}
void Init(CStdOutStream *outStream)
{
m_NeedBeClosed = false;
m_NeedNewLine = false;
CCallbackConsoleBase::Init(outStream);
}
~CUpdateCallbackConsole() { Finilize(); }
INTERFACE_IUpdateCallbackUI2(;)
};
#endif

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

@@ -2,17 +2,17 @@
#include "StdAfx.h"
#include "Common/StdInStream.h"
#include "Common/StringConvert.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 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 *kFirstQuestionMessage = "?\n";
static const char *kHelpQuestionMessage =
@@ -30,25 +30,14 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
AString scannedString = g_StdIn.ScanStringUntilNewLine();
scannedString.Trim();
if (!scannedString.IsEmpty())
switch(
::MyCharUpper(
#ifdef UNDER_CE
(wchar_t)
#endif
scannedString[0]))
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;
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;
}
}
}

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

@@ -1,9 +1,9 @@
// UserInputUtils.h
#ifndef __USERINPUTUTILS_H
#define __USERINPUTUTILS_H
#ifndef __USER_INPUT_UTILS_H
#define __USER_INPUT_UTILS_H
#include "Common/StdOutStream.h"
#include "../../../Common/StdOutStream.h"
namespace NUserAnswerMode {

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

@@ -1,24 +1,13 @@
PROG = 7z.exe
MY_CONSOLE = 1
CFLAGS = $(CFLAGS) -I ../../../ \
CFLAGS = $(CFLAGS) \
-DEXTERNAL_CODECS \
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
!ENDIF
CONSOLE_OBJS = \
$O\ConsoleClose.obj \
$O\ExtractCallbackConsole.obj \
$O\List.obj \
$O\BenchCon.obj \
$O\Main.obj \
$O\MainAr.obj \
$O\OpenCallbackConsole.obj \
$O\PercentPrinter.obj \
$O\UpdateCallbackConsole.obj \
$O\UserInputUtils.obj \
CURRENT_OBJS = \
COMMON_OBJS = \
$O\CommandLineParser.obj \
@@ -37,88 +26,46 @@ COMMON_OBJS = \
WIN_OBJS = \
$O\DLL.obj \
$O\Error.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\PropVariantConversions.obj \
$O\PropVariantConv.obj \
$O\Registry.obj \
$O\System.obj \
$O\Time.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 \
UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
$O\Bench.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 \
$O\UniqBlocks.obj \
AR_COMMON_OBJS = \
$O\OutStreamWithCRC.obj \
COMPRESS_OBJS = \
$O\CopyCoder.obj \
C_OBJS = \
$O\Alloc.obj \
$O\CpuArch.obj \
$O\Sort.obj \
$O\Threads.obj \
!include "../../Crc.mak"
!include "Console.mak"
OBJS = \
$O\StdAfx.obj \
$(CONSOLE_OBJS) \
$(COMMON_OBJS) \
$(WIN_OBJS) \
$(7ZIP_COMMON_OBJS) \
$(UI_COMMON_OBJS) \
$(AR_COMMON_OBJS) \
$O\CopyCoder.obj \
$(C_OBJS) \
$(ASM_OBJS) \
$O\resource.res
!include "../../../Build.mak"
$(CONSOLE_OBJS): $(*B).cpp
$(COMPL)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
$(WIN_OBJS): ../../../Windows/$(*B).cpp
$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
$(UI_COMMON_OBJS): ../Common/$(*B).cpp
$(COMPL)
$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
$(COMPL)
$O\CopyCoder.obj: ../../Compress/$(*B).cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)
!include "../../Asm.mak"
!include "../../7zip.mak"

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