chore: initial commit (extracted from Launchers monorepo)
Plugin: ns7zip v2.0.0 Architectures: x86-ansi, x86-unicode, amd64-unicode License: LGPL-2.1-or-later
This commit is contained in:
@@ -0,0 +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);
|
||||
}
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +1,984 @@
|
||||
# Microsoft Developer Studio Project File - Name="Console" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=Console - Win32 DebugU
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Console.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Console.mak" CFG="Console - Win32 DebugU"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Console - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Console - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Console - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Console - Win32 DebugU" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Console - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /FAcs /Yu"StdAfx.h" /FD /GF /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# 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 /nologo /subsystem:console /machine:I386 /out:"C:\UTIL\7z.exe" /OPT:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Gr /MTd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# 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 /nologo /subsystem:console /debug /machine:I386 /out:"C:\UTIL\7z.exe" /pdbtype:sept /ignore:4033
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 ReleaseU"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Console___Win32_ReleaseU"
|
||||
# PROP BASE Intermediate_Dir "Console___Win32_ReleaseU"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "ReleaseU"
|
||||
# PROP Intermediate_Dir "ReleaseU"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# 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 /nologo /subsystem:console /machine:I386 /out:"C:\UTIL\7zn.exe" /OPT:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 DebugU"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Console___Win32_DebugU"
|
||||
# PROP BASE Intermediate_Dir "Console___Win32_DebugU"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "DebugU"
|
||||
# PROP Intermediate_Dir "DebugU"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /Gr /MTd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# 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 /nologo /subsystem:console /debug /machine:I386 /out:"C:\UTIL\7z.exe" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Console - Win32 Release"
|
||||
# Name "Console - Win32 Debug"
|
||||
# Name "Console - Win32 ReleaseU"
|
||||
# Name "Console - Win32 DebugU"
|
||||
# Begin Group "Spec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# ADD CPP /Yc"StdAfx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Console"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BenchCon.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BenchCon.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ConsoleClose.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ConsoleClose.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ExtractCallbackConsole.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
|
||||
SOURCE=.\List.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainAr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OpenCallbackConsole.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\OpenCallbackConsole.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PercentPrinter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PercentPrinter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UpdateCallbackConsole.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UpdateCallbackConsole.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UserInputUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UserInputUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Windows"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\DLL.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\ErrorMsg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\ErrorMsg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileDir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileDir.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileFind.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\FileIO.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
SOURCE=..\..\..\Windows\MemoryLock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\NtCheck.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariant.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariantConv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\PropVariantConv.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Registry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
|
||||
SOURCE=..\..\..\Windows\System.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\Thread.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\TimeUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Windows\TimeUtils.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CommandLineParser.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CommandLineParser.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Common.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\ComTry.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\CRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Defs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\IntToString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\ListFileUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\ListFileUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyBuffer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyCom.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
|
||||
SOURCE=..\..\..\Common\MyVector.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\NewHandler.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StdInStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StdInStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StdOutStream.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StdOutStream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\StringToInt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\UTFConvert.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Wildcard.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\Wildcard.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "UI Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveCommandLine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveCommandLine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveExtractCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveExtractCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveOpenCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ArchiveOpenCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\Bench.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\Bench.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DefaultName.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DefaultName.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\DirItem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\EnumDirItems.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\EnumDirItems.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ExitCode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\Extract.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\Extract.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ExtractingFilePath.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
|
||||
SOURCE=..\Common\LoadCodecs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\LoadCodecs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OpenArchive.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\OpenArchive.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\Property.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\PropIDUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\PropIDUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SetProperties.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SetProperties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SortUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\SortUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\TempFiles.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\TempFiles.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\Update.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\Update.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateAction.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateAction.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateCallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdatePair.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\UpdateProduce.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Common\ZipRegistry.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "7-zip Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\CreateCoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilePathAutoRename.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilePathAutoRename.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FileStreams.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\FilterCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
|
||||
SOURCE=..\..\Common\MethodProps.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Common\ProgressUtils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\CopyCoder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\CopyCoder.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "C"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\7zCrc.c
|
||||
|
||||
!IF "$(CFG)" == "Console - Win32 Release"
|
||||
|
||||
# ADD CPP /O2
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 Debug"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 ReleaseU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 DebugU"
|
||||
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
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
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\CpuArch.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\CpuArch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.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
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "ArchiveCommon"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Archive\Common\OutStreamWithCRC.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Asm"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\Asm\x86\7zAsm.asm
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\Asm\x86\7zCrcOpt.asm
|
||||
|
||||
!IF "$(CFG)" == "Console - Win32 Release"
|
||||
|
||||
# Begin Custom Build
|
||||
OutDir=.\Release
|
||||
InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
|
||||
InputName=7zCrcOpt
|
||||
|
||||
"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
ml.exe -c -Fo$(OutDir)\$(InputName).obj $(InputPath)
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
OutDir=.\Debug
|
||||
InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
|
||||
InputName=7zCrcOpt
|
||||
|
||||
"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
ml.exe -c -omf -Fo$(OutDir)\$(InputName).obj $(InputPath)
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 ReleaseU"
|
||||
|
||||
# Begin Custom Build
|
||||
OutDir=.\ReleaseU
|
||||
InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
|
||||
InputName=7zCrcOpt
|
||||
|
||||
"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
ml.exe -c -Fo$(OutDir)\$(InputName).obj $(InputPath)
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 DebugU"
|
||||
|
||||
# Begin Custom Build
|
||||
OutDir=.\DebugU
|
||||
InputPath=..\..\..\..\Asm\x86\7zCrcOpt.asm
|
||||
InputName=7zCrcOpt
|
||||
|
||||
"$(OutDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
ml.exe -c -omf -Fo$(OutDir)\$(InputName).obj $(InputPath)
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!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
|
||||
# End Project
|
||||
@@ -0,0 +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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +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 \
|
||||
@@ -0,0 +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>
|
||||
@@ -0,0 +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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +1,825 @@
|
||||
// ExtractCallbackConsole.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/Wildcard.h"
|
||||
|
||||
#include "../../../Windows/FileDir.h"
|
||||
#include "../../../Windows/FileFind.h"
|
||||
#include "../../../Windows/TimeUtils.h"
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
#include "../../../Windows/PropVariantConv.h"
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#endif
|
||||
|
||||
#include "../../Common/FilePathAutoRename.h"
|
||||
|
||||
#include "../Common/ExtractingFilePath.h"
|
||||
|
||||
#include "ConsoleClose.h"
|
||||
#include "ExtractCallbackConsole.h"
|
||||
#include "UserInputUtils.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
|
||||
static HRESULT CheckBreak2()
|
||||
{
|
||||
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
|
||||
}
|
||||
|
||||
static const char * const kError = "ERROR: ";
|
||||
|
||||
|
||||
void CExtractScanConsole::StartScanning()
|
||||
{
|
||||
if (NeedPercents())
|
||||
_percent.Command = "Scan";
|
||||
}
|
||||
|
||||
HRESULT CExtractScanConsole::ScanProgress(const CDirItemsStat &st, const FString &path, bool /* isDir */)
|
||||
{
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.Files = st.NumDirs + st.NumFiles;
|
||||
_percent.Completed = st.GetTotalBytes();
|
||||
_percent.FileName = fs2us(path);
|
||||
_percent.Print();
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
HRESULT CExtractScanConsole::ScanError(const FString &path, DWORD systemError)
|
||||
{
|
||||
ClosePercentsAndFlush();
|
||||
|
||||
if (_se)
|
||||
{
|
||||
*_se << endl << kError << NError::MyFormatMessage(systemError) << endl;
|
||||
_se->NormalizePrint_UString(fs2us(path));
|
||||
*_se << endl << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
return HRESULT_FROM_WIN32(systemError);
|
||||
}
|
||||
|
||||
|
||||
void Print_UInt64_and_String(AString &s, UInt64 val, const char *name)
|
||||
{
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(val, temp);
|
||||
s += temp;
|
||||
s.Add_Space();
|
||||
s += name;
|
||||
}
|
||||
|
||||
void PrintSize_bytes_Smart(AString &s, UInt64 val)
|
||||
{
|
||||
Print_UInt64_and_String(s, val, "bytes");
|
||||
|
||||
if (val == 0)
|
||||
return;
|
||||
|
||||
unsigned numBits = 10;
|
||||
char c = 'K';
|
||||
char temp[4] = { 'K', 'i', 'B', 0 };
|
||||
if (val >= ((UInt64)10 << 30)) { numBits = 30; c = 'G'; }
|
||||
else if (val >= ((UInt64)10 << 20)) { numBits = 20; c = 'M'; }
|
||||
temp[0] = c;
|
||||
s += " (";
|
||||
Print_UInt64_and_String(s, ((val + ((UInt64)1 << numBits) - 1) >> numBits), temp);
|
||||
s += ')';
|
||||
}
|
||||
|
||||
void PrintSize_bytes_Smart_comma(AString &s, UInt64 val)
|
||||
{
|
||||
if (val == (UInt64)(Int64)-1)
|
||||
return;
|
||||
s += ", ";
|
||||
PrintSize_bytes_Smart(s, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Print_DirItemsStat(AString &s, const CDirItemsStat &st)
|
||||
{
|
||||
if (st.NumDirs != 0)
|
||||
{
|
||||
Print_UInt64_and_String(s, st.NumDirs, st.NumDirs == 1 ? "folder" : "folders");
|
||||
s += ", ";
|
||||
}
|
||||
Print_UInt64_and_String(s, st.NumFiles, st.NumFiles == 1 ? "file" : "files");
|
||||
PrintSize_bytes_Smart_comma(s, st.FilesSize);
|
||||
if (st.NumAltStreams != 0)
|
||||
{
|
||||
s.Add_LF();
|
||||
Print_UInt64_and_String(s, st.NumAltStreams, "alternate streams");
|
||||
PrintSize_bytes_Smart_comma(s, st.AltStreamsSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Print_DirItemsStat2(AString &s, const CDirItemsStat2 &st)
|
||||
{
|
||||
Print_DirItemsStat(s, (CDirItemsStat &)st);
|
||||
bool needLF = true;
|
||||
if (st.Anti_NumDirs != 0)
|
||||
{
|
||||
if (needLF)
|
||||
s.Add_LF();
|
||||
needLF = false;
|
||||
Print_UInt64_and_String(s, st.Anti_NumDirs, st.Anti_NumDirs == 1 ? "anti-folder" : "anti-folders");
|
||||
}
|
||||
if (st.Anti_NumFiles != 0)
|
||||
{
|
||||
if (needLF)
|
||||
s.Add_LF();
|
||||
else
|
||||
s += ", ";
|
||||
needLF = false;
|
||||
Print_UInt64_and_String(s, st.Anti_NumFiles, st.Anti_NumFiles == 1 ? "anti-file" : "anti-files");
|
||||
}
|
||||
if (st.Anti_NumAltStreams != 0)
|
||||
{
|
||||
if (needLF)
|
||||
s.Add_LF();
|
||||
else
|
||||
s += ", ";
|
||||
needLF = false;
|
||||
Print_UInt64_and_String(s, st.Anti_NumAltStreams, "anti-alternate-streams");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CExtractScanConsole::PrintStat(const CDirItemsStat &st)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
AString s;
|
||||
Print_DirItemsStat(s, st);
|
||||
*_so << s << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
#else
|
||||
#define MT_LOCK
|
||||
#endif
|
||||
|
||||
|
||||
static const char * const kTestString = "T";
|
||||
static const char * const kExtractString = "-";
|
||||
static const char * const kSkipString = ".";
|
||||
|
||||
// static const char * const kCantAutoRename = "can not create file with auto name\n";
|
||||
// static const char * const kCantRenameFile = "can not rename existing file\n";
|
||||
// static const char * const kCantDeleteOutputFile = "can not delete output file ";
|
||||
|
||||
static const char * const kMemoryExceptionMessage = "Can't allocate required memory!";
|
||||
|
||||
static const char * const kExtracting = "Extracting archive: ";
|
||||
static const char * const kTesting = "Testing archive: ";
|
||||
|
||||
static const char * const kEverythingIsOk = "Everything is Ok";
|
||||
static const char * const kNoFiles = "No files to process";
|
||||
|
||||
static const char * const kUnsupportedMethod = "Unsupported Method";
|
||||
static const char * const kCrcFailed = "CRC Failed";
|
||||
static const char * const kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
|
||||
static const char * const kDataError = "Data Error";
|
||||
static const char * const kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
|
||||
static const char * const kUnavailableData = "Unavailable data";
|
||||
static const char * const kUnexpectedEnd = "Unexpected end of data";
|
||||
static const char * const kDataAfterEnd = "There are some data after the end of the payload data";
|
||||
static const char * const kIsNotArc = "Is not archive";
|
||||
static const char * const kHeadersError = "Headers Error";
|
||||
static const char * const kWrongPassword = "Wrong password";
|
||||
|
||||
static const char * const 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 size)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.Total = size;
|
||||
_percent.Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *completeValue)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (NeedPercents())
|
||||
{
|
||||
if (completeValue)
|
||||
_percent.Completed = *completeValue;
|
||||
_percent.Print();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
static const char * const kTab = " ";
|
||||
|
||||
static void PrintFileInfo(CStdOutStream *_so, const wchar_t *path, const FILETIME *ft, const UInt64 *size)
|
||||
{
|
||||
*_so << kTab << "Path: ";
|
||||
_so->NormalizePrint_wstr(path);
|
||||
*_so << endl;
|
||||
if (size && *size != (UInt64)(Int64)-1)
|
||||
{
|
||||
AString s;
|
||||
PrintSize_bytes_Smart(s, *size);
|
||||
*_so << kTab << "Size: " << s << endl;
|
||||
}
|
||||
if (ft)
|
||||
{
|
||||
char temp[64];
|
||||
if (ConvertUtcFileTimeToString(*ft, temp, kTimestampPrintLevel_SEC))
|
||||
*_so << kTab << "Modified: " << temp << endl;
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
|
||||
Int32 *answer)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
RINOK(CheckBreak2());
|
||||
|
||||
ClosePercentsAndFlush();
|
||||
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl << "Would you like to replace the existing file:\n";
|
||||
PrintFileInfo(_so, existName, existTime, existSize);
|
||||
*_so << "with the file from archive:\n";
|
||||
PrintFileInfo(_so, newName, newTime, newSize);
|
||||
}
|
||||
|
||||
NUserAnswerMode::EEnum overwriteAnswer = ScanUserYesNoAllQuit(_so);
|
||||
|
||||
switch (overwriteAnswer)
|
||||
{
|
||||
case NUserAnswerMode::kQuit: return E_ABORT;
|
||||
case NUserAnswerMode::kNo: *answer = NOverwriteAnswer::kNo; break;
|
||||
case NUserAnswerMode::kNoAll: *answer = NOverwriteAnswer::kNoToAll; break;
|
||||
case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break;
|
||||
case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break;
|
||||
case NUserAnswerMode::kAutoRenameAll: *answer = NOverwriteAnswer::kAutoRename; break;
|
||||
case NUserAnswerMode::kEof: return E_ABORT;
|
||||
case NUserAnswerMode::kError: return E_FAIL;
|
||||
default: return E_FAIL;
|
||||
}
|
||||
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl;
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int32 /* isFolder */, Int32 askExtractMode, const UInt64 *position)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
_currentName = name;
|
||||
|
||||
const char *s;
|
||||
unsigned requiredLevel = 1;
|
||||
|
||||
switch (askExtractMode)
|
||||
{
|
||||
case NArchive::NExtract::NAskMode::kExtract: s = kExtractString; break;
|
||||
case NArchive::NExtract::NAskMode::kTest: s = kTestString; break;
|
||||
case NArchive::NExtract::NAskMode::kSkip: s = kSkipString; requiredLevel = 2; break;
|
||||
default: s = "???"; requiredLevel = 2;
|
||||
};
|
||||
|
||||
bool show2 = (LogLevel >= requiredLevel && _so);
|
||||
|
||||
if (show2)
|
||||
{
|
||||
ClosePercents_for_so();
|
||||
|
||||
_tempA = s;
|
||||
if (name)
|
||||
_tempA.Add_Space();
|
||||
*_so << _tempA;
|
||||
|
||||
_tempU.Empty();
|
||||
if (name)
|
||||
{
|
||||
_tempU = name;
|
||||
_so->Normalize_UString(_tempU);
|
||||
}
|
||||
_so->PrintUString(_tempU, _tempA);
|
||||
if (position)
|
||||
*_so << " <" << *position << ">";
|
||||
*_so << endl;
|
||||
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
|
||||
if (NeedPercents())
|
||||
{
|
||||
if (PercentsNameLevel >= 1)
|
||||
{
|
||||
_percent.FileName.Empty();
|
||||
_percent.Command.Empty();
|
||||
if (PercentsNameLevel > 1 || !show2)
|
||||
{
|
||||
_percent.Command = s;
|
||||
if (name)
|
||||
_percent.FileName = name;
|
||||
}
|
||||
}
|
||||
_percent.Print();
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
RINOK(CheckBreak2());
|
||||
|
||||
NumFileErrors_in_Current++;
|
||||
NumFileErrors++;
|
||||
|
||||
ClosePercentsAndFlush();
|
||||
if (_se)
|
||||
{
|
||||
*_se << kError << message << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &dest)
|
||||
{
|
||||
dest.Empty();
|
||||
const char *s = NULL;
|
||||
|
||||
switch (opRes)
|
||||
{
|
||||
case NArchive::NExtract::NOperationResult::kUnsupportedMethod:
|
||||
s = kUnsupportedMethod;
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kCRCError:
|
||||
s = (encrypted ? kCrcFailedEncrypted : kCrcFailed);
|
||||
break;
|
||||
case NArchive::NExtract::NOperationResult::kDataError:
|
||||
s = (encrypted ? kDataErrorEncrypted : kDataError);
|
||||
break;
|
||||
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;
|
||||
case NArchive::NExtract::NOperationResult::kWrongPassword:
|
||||
s = kWrongPassword;
|
||||
break;
|
||||
}
|
||||
|
||||
dest += kError;
|
||||
if (s)
|
||||
dest += s;
|
||||
else
|
||||
{
|
||||
dest += "Error #";
|
||||
dest.Add_UInt32(opRes);
|
||||
}
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encrypted)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (opRes == NArchive::NExtract::NOperationResult::kOK)
|
||||
{
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.Command.Empty();
|
||||
_percent.FileName.Empty();
|
||||
_percent.Files++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NumFileErrors_in_Current++;
|
||||
NumFileErrors++;
|
||||
|
||||
if (_se)
|
||||
{
|
||||
ClosePercentsAndFlush();
|
||||
|
||||
AString s;
|
||||
SetExtractErrorMessage(opRes, encrypted, s);
|
||||
|
||||
*_se << s;
|
||||
if (!_currentName.IsEmpty())
|
||||
{
|
||||
*_se << " : ";
|
||||
_se->NormalizePrint_UString(_currentName);
|
||||
}
|
||||
*_se << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::ReportExtractResult(Int32 opRes, Int32 encrypted, const wchar_t *name)
|
||||
{
|
||||
if (opRes != NArchive::NExtract::NOperationResult::kOK)
|
||||
{
|
||||
_currentName = name;
|
||||
return SetOperationResult(opRes, encrypted);
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
|
||||
HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
|
||||
{
|
||||
PasswordIsDefined = true;
|
||||
Password = password;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
MT_LOCK
|
||||
return Open_CryptoGetTextPassword(password);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
|
||||
{
|
||||
RINOK(CheckBreak2());
|
||||
|
||||
NumTryArcs++;
|
||||
ThereIsError_in_Current = false;
|
||||
ThereIsWarning_in_Current = false;
|
||||
NumFileErrors_in_Current = 0;
|
||||
|
||||
ClosePercents_for_so();
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl << (testMode ? kTesting : kExtracting);
|
||||
_so->NormalizePrint_wstr(name);
|
||||
*_so << endl;
|
||||
}
|
||||
|
||||
if (NeedPercents())
|
||||
_percent.Command = "Open";
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const CArchiveLink &arcLink);
|
||||
HRESULT Print_OpenArchive_Error(CStdOutStream &so, const CCodecs *codecs, const CArchiveLink &arcLink);
|
||||
|
||||
static 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.Add_LF();
|
||||
s += m;
|
||||
errorFlags &= ~f;
|
||||
}
|
||||
|
||||
if (errorFlags != 0)
|
||||
{
|
||||
char sz[16];
|
||||
sz[0] = '0';
|
||||
sz[1] = 'x';
|
||||
ConvertUInt32ToHex(errorFlags, sz + 2);
|
||||
if (!s.IsEmpty())
|
||||
s.Add_LF();
|
||||
s += sz;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void PrintErrorFlags(CStdOutStream &so, const char *s, UInt32 errorFlags)
|
||||
{
|
||||
if (errorFlags == 0)
|
||||
return;
|
||||
so << s << endl << GetOpenArcErrorMessage(errorFlags) << endl;
|
||||
}
|
||||
|
||||
void Add_Messsage_Pre_ArcType(UString &s, const char *pre, const wchar_t *arcType)
|
||||
{
|
||||
s.Add_LF();
|
||||
s += pre;
|
||||
s += " as [";
|
||||
s += arcType;
|
||||
s += "] archive";
|
||||
}
|
||||
|
||||
void Print_ErrorFormatIndex_Warning(CStdOutStream *_so, const CCodecs *codecs, const CArc &arc)
|
||||
{
|
||||
const CArcErrorInfo &er = arc.ErrorInfo;
|
||||
|
||||
*_so << "WARNING:\n";
|
||||
_so->NormalizePrint_UString(arc.Path);
|
||||
UString s;
|
||||
if (arc.FormatIndex == er.ErrorFormatIndex)
|
||||
{
|
||||
s.Add_LF();
|
||||
s += "The archive is open with offset";
|
||||
}
|
||||
else
|
||||
{
|
||||
Add_Messsage_Pre_ArcType(s, "Can not open the file", codecs->GetFormatNamePtr(er.ErrorFormatIndex));
|
||||
Add_Messsage_Pre_ArcType(s, "The file is open", codecs->GetFormatNamePtr(arc.FormatIndex));
|
||||
}
|
||||
|
||||
*_so << s << endl << endl;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CExtractCallbackConsole::OpenResult(
|
||||
const CCodecs *codecs, const CArchiveLink &arcLink,
|
||||
const wchar_t *name, HRESULT result)
|
||||
{
|
||||
ClosePercents();
|
||||
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.Files = 0;
|
||||
_percent.Command.Empty();
|
||||
_percent.FileName.Empty();
|
||||
}
|
||||
|
||||
|
||||
ClosePercentsAndFlush();
|
||||
|
||||
FOR_VECTOR (level, arcLink.Arcs)
|
||||
{
|
||||
const CArc &arc = arcLink.Arcs[level];
|
||||
const CArcErrorInfo &er = arc.ErrorInfo;
|
||||
|
||||
UInt32 errorFlags = er.GetErrorFlags();
|
||||
|
||||
if (errorFlags != 0 || !er.ErrorMessage.IsEmpty())
|
||||
{
|
||||
if (_se)
|
||||
{
|
||||
*_se << endl;
|
||||
if (level != 0)
|
||||
{
|
||||
_se->NormalizePrint_UString(arc.Path);
|
||||
*_se << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorFlags != 0)
|
||||
{
|
||||
if (_se)
|
||||
PrintErrorFlags(*_se, "ERRORS:", errorFlags);
|
||||
NumOpenArcErrors++;
|
||||
ThereIsError_in_Current = true;
|
||||
}
|
||||
|
||||
if (!er.ErrorMessage.IsEmpty())
|
||||
{
|
||||
if (_se)
|
||||
*_se << "ERRORS:" << endl << er.ErrorMessage << endl;
|
||||
NumOpenArcErrors++;
|
||||
ThereIsError_in_Current = true;
|
||||
}
|
||||
|
||||
if (_se)
|
||||
{
|
||||
*_se << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 warningFlags = er.GetWarningFlags();
|
||||
|
||||
if (warningFlags != 0 || !er.WarningMessage.IsEmpty())
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl;
|
||||
if (level != 0)
|
||||
{
|
||||
_so->NormalizePrint_UString(arc.Path);
|
||||
*_so << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (warningFlags != 0)
|
||||
{
|
||||
if (_so)
|
||||
PrintErrorFlags(*_so, "WARNINGS:", warningFlags);
|
||||
NumOpenArcWarnings++;
|
||||
ThereIsWarning_in_Current = true;
|
||||
}
|
||||
|
||||
if (!er.WarningMessage.IsEmpty())
|
||||
{
|
||||
if (_so)
|
||||
*_so << "WARNINGS:" << endl << er.WarningMessage << endl;
|
||||
NumOpenArcWarnings++;
|
||||
ThereIsWarning_in_Current = true;
|
||||
}
|
||||
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl;
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (er.ErrorFormatIndex >= 0)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
Print_ErrorFormatIndex_Warning(_so, codecs, arc);
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
ThereIsWarning_in_Current = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink));
|
||||
*_so << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NumCantOpenArcs++;
|
||||
if (_so)
|
||||
_so->Flush();
|
||||
if (_se)
|
||||
{
|
||||
*_se << kError;
|
||||
_se->NormalizePrint_wstr(name);
|
||||
*_se << endl;
|
||||
HRESULT res = Print_OpenArchive_Error(*_se, codecs, arcLink);
|
||||
RINOK(res);
|
||||
if (result == S_FALSE)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result == E_OUTOFMEMORY)
|
||||
*_se << "Can't allocate required memory";
|
||||
else
|
||||
*_se << NError::MyFormatMessage(result);
|
||||
*_se << endl;
|
||||
}
|
||||
_se->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackConsole::ThereAreNoFiles()
|
||||
{
|
||||
ClosePercents_for_so();
|
||||
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl << kNoFiles << endl;
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.ClosePrint(true);
|
||||
_percent.Command.Empty();
|
||||
_percent.FileName.Empty();
|
||||
}
|
||||
|
||||
if (_so)
|
||||
_so->Flush();
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
if (NumFileErrors_in_Current == 0 && !ThereIsError_in_Current)
|
||||
{
|
||||
if (ThereIsWarning_in_Current)
|
||||
NumArcsWithWarnings++;
|
||||
else
|
||||
NumOkArcs++;
|
||||
if (_so)
|
||||
*_so << kEverythingIsOk << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumArcsWithError++;
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl;
|
||||
if (NumFileErrors_in_Current != 0)
|
||||
*_so << "Sub items Errors: " << NumFileErrors_in_Current << endl;
|
||||
}
|
||||
}
|
||||
if (_so && NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
NumArcsWithError++;
|
||||
if (result == E_ABORT || result == ERROR_DISK_FULL)
|
||||
return result;
|
||||
|
||||
if (_se)
|
||||
{
|
||||
*_se << endl << kError;
|
||||
if (result == E_OUTOFMEMORY)
|
||||
*_se << kMemoryExceptionMessage;
|
||||
else
|
||||
*_se << NError::MyFormatMessage(result);
|
||||
*_se << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +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;
|
||||
}
|
||||
@@ -0,0 +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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +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;
|
||||
}
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +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;
|
||||
}
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +1,3 @@
|
||||
// StdAfx.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
// StdAfx.h
|
||||
|
||||
#ifndef __STDAFX_H
|
||||
#define __STDAFX_H
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,702 @@
|
||||
// UpdateCallbackConsole.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#endif
|
||||
|
||||
#include "ConsoleClose.h"
|
||||
#include "UserInputUtils.h"
|
||||
#include "UpdateCallbackConsole.h"
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
|
||||
#else
|
||||
#define MT_LOCK
|
||||
#endif
|
||||
|
||||
static const wchar_t * const kEmptyFileAlias = L"[Content]";
|
||||
|
||||
static const char * const kOpenArchiveMessage = "Open archive: ";
|
||||
static const char * const kCreatingArchiveMessage = "Creating archive: ";
|
||||
static const char * const kUpdatingArchiveMessage = "Updating archive: ";
|
||||
static const char * const kScanningMessage = "Scanning the drive:";
|
||||
|
||||
static const char * const kError = "ERROR: ";
|
||||
static const char * const kWarning = "WARNING: ";
|
||||
|
||||
static HRESULT CheckBreak2()
|
||||
{
|
||||
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
|
||||
}
|
||||
|
||||
HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const CArchiveLink &arcLink);
|
||||
HRESULT Print_OpenArchive_Error(CStdOutStream &so, const CCodecs *codecs, const CArchiveLink &arcLink);
|
||||
|
||||
void PrintErrorFlags(CStdOutStream &so, const char *s, UInt32 errorFlags);
|
||||
|
||||
void Print_ErrorFormatIndex_Warning(CStdOutStream *_so, const CCodecs *codecs, const CArc &arc);
|
||||
|
||||
HRESULT CUpdateCallbackConsole::OpenResult(
|
||||
const CCodecs *codecs, const CArchiveLink &arcLink,
|
||||
const wchar_t *name, HRESULT result)
|
||||
{
|
||||
ClosePercents2();
|
||||
|
||||
FOR_VECTOR (level, arcLink.Arcs)
|
||||
{
|
||||
const CArc &arc = arcLink.Arcs[level];
|
||||
const CArcErrorInfo &er = arc.ErrorInfo;
|
||||
|
||||
UInt32 errorFlags = er.GetErrorFlags();
|
||||
|
||||
if (errorFlags != 0 || !er.ErrorMessage.IsEmpty())
|
||||
{
|
||||
if (_se)
|
||||
{
|
||||
*_se << endl;
|
||||
if (level != 0)
|
||||
*_se << arc.Path << endl;
|
||||
}
|
||||
|
||||
if (errorFlags != 0)
|
||||
{
|
||||
if (_se)
|
||||
PrintErrorFlags(*_se, "ERRORS:", errorFlags);
|
||||
}
|
||||
|
||||
if (!er.ErrorMessage.IsEmpty())
|
||||
{
|
||||
if (_se)
|
||||
*_se << "ERRORS:" << endl << er.ErrorMessage << endl;
|
||||
}
|
||||
|
||||
if (_se)
|
||||
{
|
||||
*_se << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
UInt32 warningFlags = er.GetWarningFlags();
|
||||
|
||||
if (warningFlags != 0 || !er.WarningMessage.IsEmpty())
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl;
|
||||
if (level != 0)
|
||||
*_so << arc.Path << endl;
|
||||
}
|
||||
|
||||
if (warningFlags != 0)
|
||||
{
|
||||
if (_so)
|
||||
PrintErrorFlags(*_so, "WARNINGS:", warningFlags);
|
||||
}
|
||||
|
||||
if (!er.WarningMessage.IsEmpty())
|
||||
{
|
||||
if (_so)
|
||||
*_so << "WARNINGS:" << endl << er.WarningMessage << endl;
|
||||
}
|
||||
|
||||
if (_so)
|
||||
{
|
||||
*_so << endl;
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (er.ErrorFormatIndex >= 0)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
Print_ErrorFormatIndex_Warning(_so, codecs, arc);
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result == S_OK)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
RINOK(Print_OpenArchive_Props(*_so, codecs, arcLink));
|
||||
*_so << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_so)
|
||||
_so->Flush();
|
||||
if (_se)
|
||||
{
|
||||
*_se << kError;
|
||||
_se->NormalizePrint_wstr(name);
|
||||
*_se << endl;
|
||||
HRESULT res = Print_OpenArchive_Error(*_se, codecs, arcLink);
|
||||
RINOK(res);
|
||||
_se->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::StartScanning()
|
||||
{
|
||||
if (_so)
|
||||
*_so << kScanningMessage << endl;
|
||||
_percent.Command = "Scan ";
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::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 CheckBreak();
|
||||
}
|
||||
|
||||
void CCallbackConsoleBase::CommonError(const FString &path, DWORD systemError, bool isWarning)
|
||||
{
|
||||
ClosePercents2();
|
||||
|
||||
if (_se)
|
||||
{
|
||||
if (_so)
|
||||
_so->Flush();
|
||||
|
||||
*_se << endl << (isWarning ? kWarning : kError)
|
||||
<< NError::MyFormatMessage(systemError)
|
||||
<< endl;
|
||||
_se->NormalizePrint_UString(fs2us(path));
|
||||
*_se << endl << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HRESULT CCallbackConsoleBase::ScanError_Base(const FString &path, DWORD systemError)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
ScanErrors.AddError(path, systemError);
|
||||
CommonError(path, systemError, true);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CCallbackConsoleBase::OpenFileError_Base(const FString &path, DWORD systemError)
|
||||
{
|
||||
MT_LOCK
|
||||
FailedFiles.AddError(path, systemError);
|
||||
/*
|
||||
if (systemError == ERROR_SHARING_VIOLATION)
|
||||
{
|
||||
*/
|
||||
CommonError(path, systemError, true);
|
||||
return S_FALSE;
|
||||
/*
|
||||
}
|
||||
return systemError;
|
||||
*/
|
||||
}
|
||||
|
||||
HRESULT CCallbackConsoleBase::ReadingFileError_Base(const FString &path, DWORD systemError)
|
||||
{
|
||||
MT_LOCK
|
||||
CommonError(path, systemError, false);
|
||||
return HRESULT_FROM_WIN32(systemError);
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::ScanError(const FString &path, DWORD systemError)
|
||||
{
|
||||
return ScanError_Base(path, systemError);
|
||||
}
|
||||
|
||||
|
||||
static void PrintPropPair(AString &s, const char *name, UInt64 val)
|
||||
{
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(val, temp);
|
||||
s += name;
|
||||
s += ": ";
|
||||
s += temp;
|
||||
}
|
||||
|
||||
void PrintSize_bytes_Smart(AString &s, UInt64 val);
|
||||
void Print_DirItemsStat(AString &s, const CDirItemsStat &st);
|
||||
void Print_DirItemsStat2(AString &s, const CDirItemsStat2 &st);
|
||||
|
||||
HRESULT CUpdateCallbackConsole::FinishScanning(const CDirItemsStat &st)
|
||||
{
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.ClosePrint(true);
|
||||
_percent.ClearCurState();
|
||||
}
|
||||
|
||||
if (_so)
|
||||
{
|
||||
AString s;
|
||||
Print_DirItemsStat(s, st);
|
||||
*_so << s << endl << endl;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const char * const k_StdOut_ArcName = "StdOut";
|
||||
|
||||
HRESULT CUpdateCallbackConsole::StartOpenArchive(const wchar_t *name)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
*_so << kOpenArchiveMessage;
|
||||
if (name)
|
||||
*_so << name;
|
||||
else
|
||||
*_so << k_StdOut_ArcName;
|
||||
*_so << endl;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::StartArchive(const wchar_t *name, bool updating)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
*_so << (updating ? kUpdatingArchiveMessage : kCreatingArchiveMessage);
|
||||
if (name)
|
||||
_so->NormalizePrint_wstr(name);
|
||||
else
|
||||
*_so << k_StdOut_ArcName;
|
||||
*_so << endl << endl;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::FinishArchive(const CFinishArchiveStat &st)
|
||||
{
|
||||
ClosePercents2();
|
||||
|
||||
if (_so)
|
||||
{
|
||||
AString s;
|
||||
// Print_UInt64_and_String(s, _percent.Files == 1 ? "file" : "files", _percent.Files);
|
||||
PrintPropPair(s, "Files read from disk", _percent.Files);
|
||||
s.Add_LF();
|
||||
s += "Archive size: ";
|
||||
PrintSize_bytes_Smart(s, st.OutArcFileSize);
|
||||
s.Add_LF();
|
||||
*_so << endl;
|
||||
*_so << s;
|
||||
// *_so << endl;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::WriteSfx(const wchar_t *name, UInt64 size)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
*_so << "Write SFX: ";
|
||||
*_so << name;
|
||||
AString s (" : ");
|
||||
PrintSize_bytes_Smart(s, size);
|
||||
*_so << s << endl;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CUpdateCallbackConsole::DeletingAfterArchiving(const FString &path, bool /* isDir */)
|
||||
{
|
||||
if (LogLevel > 0 && _so)
|
||||
{
|
||||
ClosePercents_for_so();
|
||||
|
||||
if (!DeleteMessageWasShown)
|
||||
{
|
||||
if (_so)
|
||||
*_so << endl << ": Removing files after including to archive" << endl;
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
_tempA = "Removing";
|
||||
_tempA.Add_Space();
|
||||
*_so << _tempA;
|
||||
_tempU = fs2us(path);
|
||||
_so->Normalize_UString(_tempU);
|
||||
_so->PrintUString(_tempU, _tempA);
|
||||
*_so << endl;
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!DeleteMessageWasShown)
|
||||
{
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.ClearCurState();
|
||||
}
|
||||
DeleteMessageWasShown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_percent.Files++;
|
||||
}
|
||||
|
||||
if (NeedPercents())
|
||||
{
|
||||
// if (!FullLog)
|
||||
{
|
||||
_percent.Command = "Removing";
|
||||
_percent.FileName = fs2us(path);
|
||||
}
|
||||
_percent.Print();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CUpdateCallbackConsole::FinishDeletingAfterArchiving()
|
||||
{
|
||||
ClosePercents2();
|
||||
if (_so && DeleteMessageWasShown)
|
||||
*_so << endl;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::CheckBreak()
|
||||
{
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT CUpdateCallbackConsole::Finalize()
|
||||
{
|
||||
// MT_LOCK
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void static PrintToDoStat(CStdOutStream *_so, const CDirItemsStat2 &stat, const char *name)
|
||||
{
|
||||
AString s;
|
||||
Print_DirItemsStat2(s, stat);
|
||||
*_so << name << ": " << s << endl;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetNumItems(const CArcToDoStat &stat)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
ClosePercents_for_so();
|
||||
if (!stat.DeleteData.IsEmpty())
|
||||
{
|
||||
*_so << endl;
|
||||
PrintToDoStat(_so, stat.DeleteData, "Delete data from archive");
|
||||
}
|
||||
if (!stat.OldData.IsEmpty())
|
||||
PrintToDoStat(_so, stat.OldData, "Keep old data in archive");
|
||||
// if (!stat.NewData.IsEmpty())
|
||||
{
|
||||
PrintToDoStat(_so, stat.NewData, "Add new data to archive");
|
||||
}
|
||||
*_so << endl;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetTotal(UInt64 size)
|
||||
{
|
||||
MT_LOCK
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.Total = size;
|
||||
_percent.Print();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetCompleted(const UInt64 *completeValue)
|
||||
{
|
||||
MT_LOCK
|
||||
if (completeValue)
|
||||
{
|
||||
if (NeedPercents())
|
||||
{
|
||||
_percent.Completed = *completeValue;
|
||||
_percent.Print();
|
||||
}
|
||||
}
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetRatioInfo(const UInt64 * /* inSize */, const UInt64 * /* outSize */)
|
||||
{
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
HRESULT CCallbackConsoleBase::PrintProgress(const wchar_t *name, const char *command, bool showInLog)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
bool show2 = (showInLog && _so);
|
||||
|
||||
if (show2)
|
||||
{
|
||||
ClosePercents_for_so();
|
||||
|
||||
_tempA = command;
|
||||
if (name)
|
||||
_tempA.Add_Space();
|
||||
*_so << _tempA;
|
||||
|
||||
_tempU.Empty();
|
||||
if (name)
|
||||
{
|
||||
_tempU = name;
|
||||
_so->Normalize_UString(_tempU);
|
||||
}
|
||||
_so->PrintUString(_tempU, _tempA);
|
||||
*_so << endl;
|
||||
if (NeedFlush)
|
||||
_so->Flush();
|
||||
}
|
||||
|
||||
if (NeedPercents())
|
||||
{
|
||||
if (PercentsNameLevel >= 1)
|
||||
{
|
||||
_percent.FileName.Empty();
|
||||
_percent.Command.Empty();
|
||||
if (PercentsNameLevel > 1 || !show2)
|
||||
{
|
||||
_percent.Command = command;
|
||||
if (name)
|
||||
_percent.FileName = name;
|
||||
}
|
||||
}
|
||||
_percent.Print();
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool /* isDir */, bool isAnti, UInt32 mode)
|
||||
{
|
||||
if (StdOutMode)
|
||||
return S_OK;
|
||||
|
||||
if (!name || name[0] == 0)
|
||||
name = kEmptyFileAlias;
|
||||
|
||||
unsigned requiredLevel = 1;
|
||||
|
||||
const char *s;
|
||||
if (mode == NUpdateNotifyOp::kAdd ||
|
||||
mode == NUpdateNotifyOp::kUpdate)
|
||||
{
|
||||
if (isAnti)
|
||||
s = "Anti";
|
||||
else if (mode == NUpdateNotifyOp::kAdd)
|
||||
s = "+";
|
||||
else
|
||||
s = "U";
|
||||
}
|
||||
else
|
||||
{
|
||||
requiredLevel = 3;
|
||||
if (mode == NUpdateNotifyOp::kAnalyze)
|
||||
s = "A";
|
||||
else
|
||||
s = "Reading";
|
||||
}
|
||||
|
||||
return PrintProgress(name, s, LogLevel >= requiredLevel);
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::OpenFileError(const FString &path, DWORD systemError)
|
||||
{
|
||||
return OpenFileError_Base(path, systemError);
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::ReadingFileError(const FString &path, DWORD systemError)
|
||||
{
|
||||
return ReadingFileError_Base(path, systemError);
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetOperationResult(Int32)
|
||||
{
|
||||
MT_LOCK
|
||||
_percent.Files++;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &dest);
|
||||
|
||||
HRESULT CUpdateCallbackConsole::ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name)
|
||||
{
|
||||
// if (StdOutMode) return S_OK;
|
||||
|
||||
if (opRes != NArchive::NExtract::NOperationResult::kOK)
|
||||
{
|
||||
ClosePercents2();
|
||||
|
||||
if (_se)
|
||||
{
|
||||
if (_so)
|
||||
_so->Flush();
|
||||
|
||||
AString s;
|
||||
SetExtractErrorMessage(opRes, isEncrypted, s);
|
||||
*_se << s << " : " << endl;
|
||||
_se->NormalizePrint_wstr(name);
|
||||
*_se << endl << endl;
|
||||
_se->Flush();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CUpdateCallbackConsole::ReportUpdateOpeartion(UInt32 op, const wchar_t *name, bool /* isDir */)
|
||||
{
|
||||
// if (StdOutMode) return S_OK;
|
||||
|
||||
char temp[16];
|
||||
const char *s;
|
||||
|
||||
unsigned requiredLevel = 1;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case NUpdateNotifyOp::kAdd: s = "+"; break;
|
||||
case NUpdateNotifyOp::kUpdate: s = "U"; break;
|
||||
case NUpdateNotifyOp::kAnalyze: s = "A"; requiredLevel = 3; break;
|
||||
case NUpdateNotifyOp::kReplicate: s = "="; requiredLevel = 3; break;
|
||||
case NUpdateNotifyOp::kRepack: s = "R"; requiredLevel = 2; break;
|
||||
case NUpdateNotifyOp::kSkip: s = "."; requiredLevel = 2; break;
|
||||
case NUpdateNotifyOp::kDelete: s = "D"; requiredLevel = 3; break;
|
||||
case NUpdateNotifyOp::kHeader: s = "Header creation"; requiredLevel = 100; break;
|
||||
default:
|
||||
{
|
||||
temp[0] = 'o';
|
||||
temp[1] = 'p';
|
||||
ConvertUInt64ToString(op, temp + 2);
|
||||
s = temp;
|
||||
}
|
||||
}
|
||||
|
||||
return PrintProgress(name, s, LogLevel >= requiredLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT CUpdateCallbackConsole::SetPassword(const UString &
|
||||
#ifndef _NO_CRYPTO
|
||||
password
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifndef _NO_CRYPTO
|
||||
PasswordIsDefined = true;
|
||||
Password = password;
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
*password = NULL;
|
||||
|
||||
#ifdef _NO_CRYPTO
|
||||
|
||||
*passwordIsDefined = false;
|
||||
return S_OK;
|
||||
|
||||
#else
|
||||
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
if (AskPassword)
|
||||
{
|
||||
RINOK(GetPassword_HRESULT(_so, Password));
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
}
|
||||
*passwordIsDefined = BoolToInt(PasswordIsDefined);
|
||||
return StringToBstr(Password, password);
|
||||
|
||||
#endif
|
||||
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
*password = NULL;
|
||||
|
||||
#ifdef _NO_CRYPTO
|
||||
|
||||
return E_NOTIMPL;
|
||||
|
||||
#else
|
||||
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
{
|
||||
RINOK(GetPassword_HRESULT(_so, Password))
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
}
|
||||
return StringToBstr(Password, password);
|
||||
|
||||
#endif
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::ShowDeleteFile(const wchar_t *name, bool /* isDir */)
|
||||
{
|
||||
if (StdOutMode)
|
||||
return S_OK;
|
||||
|
||||
if (LogLevel > 7)
|
||||
{
|
||||
if (!name || name[0] == 0)
|
||||
name = kEmptyFileAlias;
|
||||
return PrintProgress(name, "D", true);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +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;
|
||||
}
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +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"
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_APP("7-Zip Console" , "7z")
|
||||
|
||||
#ifndef UNDER_CE
|
||||
1 24 MOVEABLE PURE "Console.manifest"
|
||||
#endif
|
||||
Reference in New Issue
Block a user