mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 22:06:59 -06:00
15.06
This commit is contained in:
committed by
Kornel Lesiński
parent
54490d51d5
commit
cba375916f
@@ -4,6 +4,10 @@
|
||||
|
||||
#include "ConsoleClose.h"
|
||||
|
||||
#if !defined(UNDER_CE) && defined(_WIN32)
|
||||
#include "../../../Common/MyWindows.h"
|
||||
#endif
|
||||
|
||||
namespace NConsoleClose {
|
||||
|
||||
unsigned g_BreakCounter = 0;
|
||||
|
||||
@@ -123,6 +123,7 @@ static const char * const kPropIdToName[] =
|
||||
, "Stream ID"
|
||||
, "Read-only"
|
||||
, "Out Name"
|
||||
, "Copy Link"
|
||||
};
|
||||
|
||||
static const char kEmptyAttribChar = '.';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <Psapi.h>
|
||||
|
||||
#include "../../../../C/CpuArch.h"
|
||||
@@ -230,42 +232,51 @@ static void PrintWarningsPaths(const CErrorPathCodes &pc, CStdOutStream &so)
|
||||
}
|
||||
|
||||
static int WarningsCheck(HRESULT result, const CCallbackConsoleBase &callback,
|
||||
const CUpdateErrorInfo &errorInfo, CStdOutStream &so, bool showHeaders)
|
||||
const CUpdateErrorInfo &errorInfo,
|
||||
CStdOutStream *so,
|
||||
CStdOutStream *se,
|
||||
bool showHeaders)
|
||||
{
|
||||
int exitCode = NExitCode::kSuccess;
|
||||
|
||||
if (callback.ScanErrors.Paths.Size() != 0)
|
||||
{
|
||||
so << endl;
|
||||
so << "Scan WARNINGS for files and folders:" << endl << endl;
|
||||
PrintWarningsPaths(callback.ScanErrors, so);
|
||||
so << "Scan WARNINGS: " << callback.ScanErrors.Paths.Size();
|
||||
so << endl;
|
||||
if (se)
|
||||
{
|
||||
*se << endl;
|
||||
*se << "Scan WARNINGS for files and folders:" << endl << endl;
|
||||
PrintWarningsPaths(callback.ScanErrors, *se);
|
||||
*se << "Scan WARNINGS: " << callback.ScanErrors.Paths.Size();
|
||||
*se << endl;
|
||||
}
|
||||
exitCode = NExitCode::kWarning;
|
||||
}
|
||||
|
||||
if (result != S_OK || errorInfo.ThereIsError())
|
||||
{
|
||||
UString message;
|
||||
if (!errorInfo.Message.IsEmpty())
|
||||
if (se)
|
||||
{
|
||||
message.AddAscii(errorInfo.Message);
|
||||
message.Add_LF();
|
||||
}
|
||||
{
|
||||
FOR_VECTOR(i, errorInfo.FileNames)
|
||||
UString message;
|
||||
if (!errorInfo.Message.IsEmpty())
|
||||
{
|
||||
message += fs2us(errorInfo.FileNames[i]);
|
||||
message.AddAscii(errorInfo.Message);
|
||||
message.Add_LF();
|
||||
}
|
||||
{
|
||||
FOR_VECTOR(i, errorInfo.FileNames)
|
||||
{
|
||||
message += fs2us(errorInfo.FileNames[i]);
|
||||
message.Add_LF();
|
||||
}
|
||||
}
|
||||
if (errorInfo.SystemError != 0)
|
||||
{
|
||||
message += NError::MyFormatMessage(errorInfo.SystemError);
|
||||
message.Add_LF();
|
||||
}
|
||||
if (!message.IsEmpty())
|
||||
*se << L"\nError:\n" << message;
|
||||
}
|
||||
if (errorInfo.SystemError != 0)
|
||||
{
|
||||
message += NError::MyFormatMessage(errorInfo.SystemError);
|
||||
message.Add_LF();
|
||||
}
|
||||
if (!message.IsEmpty())
|
||||
so << L"\nError:\n" << message;
|
||||
|
||||
// we will work with (result) later
|
||||
// throw CSystemException(result);
|
||||
@@ -277,17 +288,25 @@ static int WarningsCheck(HRESULT result, const CCallbackConsoleBase &callback,
|
||||
{
|
||||
if (showHeaders)
|
||||
if (callback.ScanErrors.Paths.Size() == 0)
|
||||
so << kEverythingIsOk << endl;
|
||||
if (so)
|
||||
{
|
||||
if (se)
|
||||
se->Flush();
|
||||
*so << kEverythingIsOk << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
so << endl;
|
||||
so << "WARNINGS for files:" << endl << endl;
|
||||
PrintWarningsPaths(callback.FailedFiles, so);
|
||||
so << "WARNING: Cannot open " << numErrors << " file";
|
||||
if (numErrors > 1)
|
||||
so << 's';
|
||||
so << endl;
|
||||
if (se)
|
||||
{
|
||||
*se << endl;
|
||||
*se << "WARNINGS for files:" << endl << endl;
|
||||
PrintWarningsPaths(callback.FailedFiles, *se);
|
||||
*se << "WARNING: Cannot open " << numErrors << " file";
|
||||
if (numErrors > 1)
|
||||
*se << 's';
|
||||
*se << endl;
|
||||
}
|
||||
exitCode = NExitCode::kWarning;
|
||||
}
|
||||
|
||||
@@ -473,10 +492,7 @@ int Main2(
|
||||
CStdOutStream *percentsStream = NULL;
|
||||
if (options.Number_for_Percents != k_OutStream_disabled)
|
||||
percentsStream = (options.Number_for_Percents == k_OutStream_stderr) ? &g_StdErr : &g_StdOut;;
|
||||
|
||||
CStdOutStream &so = (g_StdStream ? *g_StdStream : g_StdOut);
|
||||
|
||||
|
||||
if (options.HelpMode)
|
||||
{
|
||||
ShowCopyrightAndHelp(g_StdStream, true);
|
||||
@@ -589,6 +605,7 @@ int Main2(
|
||||
|
||||
if (options.Command.CommandType == NCommandType::kInfo)
|
||||
{
|
||||
CStdOutStream &so = (g_StdStream ? *g_StdStream : g_StdOut);
|
||||
unsigned i;
|
||||
|
||||
#ifdef EXTERNAL_CODECS
|
||||
@@ -754,6 +771,7 @@ int Main2(
|
||||
}
|
||||
else if (options.Command.CommandType == NCommandType::kBenchmark)
|
||||
{
|
||||
CStdOutStream &so = (g_StdStream ? *g_StdStream : g_StdOut);
|
||||
hresultMain = BenchCon(EXTERNAL_CODECS_VARS_L
|
||||
options.Properties, options.NumIterations, (FILE *)so);
|
||||
if (hresultMain == S_FALSE)
|
||||
@@ -890,73 +908,91 @@ int Main2(
|
||||
hresultMain = E_FAIL;
|
||||
}
|
||||
|
||||
so << endl;
|
||||
CStdOutStream *so = g_StdStream;
|
||||
|
||||
if (ecs->NumTryArcs > 1)
|
||||
{
|
||||
so << "Archives: " << ecs->NumTryArcs << endl;
|
||||
so << "OK archives: " << ecs->NumOkArcs << endl;
|
||||
}
|
||||
bool isError = false;
|
||||
|
||||
if (so)
|
||||
{
|
||||
*so << endl;
|
||||
|
||||
if (ecs->NumTryArcs > 1)
|
||||
{
|
||||
*so << "Archives: " << ecs->NumTryArcs << endl;
|
||||
*so << "OK archives: " << ecs->NumOkArcs << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (ecs->NumCantOpenArcs != 0)
|
||||
{
|
||||
isError = true;
|
||||
so << "Can't open as archive: " << ecs->NumCantOpenArcs << endl;
|
||||
if (so)
|
||||
*so << "Can't open as archive: " << ecs->NumCantOpenArcs << endl;
|
||||
}
|
||||
|
||||
if (ecs->NumArcsWithError != 0)
|
||||
{
|
||||
isError = true;
|
||||
so << "Archives with Errors: " << ecs->NumArcsWithError << endl;
|
||||
if (so)
|
||||
*so << "Archives with Errors: " << ecs->NumArcsWithError << endl;
|
||||
}
|
||||
if (ecs->NumArcsWithWarnings != 0)
|
||||
so << "Archives with Warnings: " << ecs->NumArcsWithWarnings << endl;
|
||||
|
||||
if (ecs->NumOpenArcWarnings != 0)
|
||||
if (so)
|
||||
{
|
||||
so << endl;
|
||||
if (ecs->NumArcsWithWarnings != 0)
|
||||
*so << "Archives with Warnings: " << ecs->NumArcsWithWarnings << endl;
|
||||
|
||||
if (ecs->NumOpenArcWarnings != 0)
|
||||
so << "Warnings: " << ecs->NumOpenArcWarnings << endl;
|
||||
{
|
||||
*so << endl;
|
||||
if (ecs->NumOpenArcWarnings != 0)
|
||||
*so << "Warnings: " << ecs->NumOpenArcWarnings << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (ecs->NumOpenArcErrors != 0)
|
||||
{
|
||||
isError = true;
|
||||
so << endl;
|
||||
if (ecs->NumOpenArcErrors != 0)
|
||||
so << "Open Errors: " << ecs->NumOpenArcErrors << endl;
|
||||
if (so)
|
||||
{
|
||||
*so << endl;
|
||||
if (ecs->NumOpenArcErrors != 0)
|
||||
*so << "Open Errors: " << ecs->NumOpenArcErrors << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (isError)
|
||||
retCode = NExitCode::kFatalError;
|
||||
|
||||
if (so)
|
||||
if (ecs->NumArcsWithError != 0 || ecs->NumFileErrors != 0)
|
||||
{
|
||||
// if (ecs->NumArchives > 1)
|
||||
{
|
||||
so << endl;
|
||||
*so << endl;
|
||||
if (ecs->NumFileErrors != 0)
|
||||
so << "Sub items Errors: " << ecs->NumFileErrors << endl;
|
||||
*so << "Sub items Errors: " << ecs->NumFileErrors << endl;
|
||||
}
|
||||
}
|
||||
else if (hresultMain == S_OK)
|
||||
{
|
||||
if (stat.NumFolders != 0)
|
||||
so << "Folders: " << stat.NumFolders << endl;
|
||||
*so << "Folders: " << stat.NumFolders << endl;
|
||||
if (stat.NumFiles != 1 || stat.NumFolders != 0 || stat.NumAltStreams != 0)
|
||||
so << "Files: " << stat.NumFiles << endl;
|
||||
*so << "Files: " << stat.NumFiles << endl;
|
||||
if (stat.NumAltStreams != 0)
|
||||
{
|
||||
so << "Alternate Streams: " << stat.NumAltStreams << endl;
|
||||
so << "Alternate Streams Size: " << stat.AltStreams_UnpackSize << endl;
|
||||
*so << "Alternate Streams: " << stat.NumAltStreams << endl;
|
||||
*so << "Alternate Streams Size: " << stat.AltStreams_UnpackSize << endl;
|
||||
}
|
||||
|
||||
so
|
||||
*so
|
||||
<< "Size: " << stat.UnpackSize << endl
|
||||
<< "Compressed: " << stat.PackSize << endl;
|
||||
if (hashCalc)
|
||||
{
|
||||
so << endl;
|
||||
PrintHashStat(so, hb);
|
||||
*so << endl;
|
||||
PrintHashStat(*so, hb);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1047,9 +1083,14 @@ int Main2(
|
||||
|
||||
callback.ClosePercents2();
|
||||
|
||||
retCode = WarningsCheck(hresultMain, callback, errorInfo, so,
|
||||
// options.EnableHeaders
|
||||
true);
|
||||
CStdOutStream *se = g_StdStream;
|
||||
if (!se)
|
||||
se = g_ErrStream;
|
||||
|
||||
retCode = WarningsCheck(hresultMain, callback, errorInfo,
|
||||
g_StdStream, se,
|
||||
true // options.EnableHeaders
|
||||
);
|
||||
}
|
||||
else if (options.Command.CommandType == NCommandType::kHash)
|
||||
{
|
||||
@@ -1068,7 +1109,10 @@ int Main2(
|
||||
errorInfoString, &callback);
|
||||
CUpdateErrorInfo errorInfo;
|
||||
errorInfo.Message = errorInfoString;
|
||||
retCode = WarningsCheck(hresultMain, callback, errorInfo, so, options.EnableHeaders);
|
||||
CStdOutStream *se = g_StdStream;
|
||||
if (!se)
|
||||
se = g_ErrStream;
|
||||
retCode = WarningsCheck(hresultMain, callback, errorInfo, g_StdStream, se, options.EnableHeaders);
|
||||
}
|
||||
else
|
||||
ShowMessageAndThrowException(kUserErrorMessage, NExitCode::kUserError);
|
||||
|
||||
Reference in New Issue
Block a user