This commit is contained in:
Igor Pavlov
2018-05-02 22:28:04 +01:00
committed by Kornel
parent f19b649c73
commit 18dc2b4161
121 changed files with 3523 additions and 1866 deletions

View File

@@ -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>

View File

@@ -60,8 +60,9 @@ HRESULT CExtractScanConsole::ScanError(const FString &path, DWORD systemError)
if (_se)
{
*_se << endl << kError << NError::MyFormatMessage(systemError) << endl <<
fs2us(path) << endl << endl;
*_se << endl << kError << NError::MyFormatMessage(systemError) << endl;
_se->NormalizePrint_UString(fs2us(path));
*_se << endl << endl;
_se->Flush();
}
return HRESULT_FROM_WIN32(systemError);
@@ -251,7 +252,9 @@ static const char * const kTab = " ";
static void PrintFileInfo(CStdOutStream *_so, const wchar_t *path, const FILETIME *ft, const UInt64 *size)
{
*_so << kTab << "Path: " << path << endl;
*_so << kTab << "Path: ";
_so->NormalizePrint_wstr(path);
*_so << endl;
if (size && *size != (UInt64)(Int64)-1)
{
AString s;
@@ -340,7 +343,10 @@ STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, Int3
_tempU.Empty();
if (name)
{
_tempU = name;
_so->Normalize_UString(_tempU);
}
_so->PrintUString(_tempU, _tempA);
if (position)
*_so << " <" << *position << ">";
@@ -461,7 +467,10 @@ STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 opRes, Int32 encr
*_se << s;
if (!_currentName.IsEmpty())
*_se << " : " << _currentName;
{
*_se << " : ";
_se->NormalizePrint_UString(_currentName);
}
*_se << endl;
_se->Flush();
}
@@ -513,7 +522,11 @@ HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name, bool testMode)
ClosePercents_for_so();
if (_so)
*_so << endl << (testMode ? kTesting : kExtracting) << name << endl;
{
*_so << endl << (testMode ? kTesting : kExtracting);
_so->NormalizePrint_wstr(name);
*_so << endl;
}
if (NeedPercents())
_percent.Command = "Open";
@@ -573,8 +586,9 @@ void Print_ErrorFormatIndex_Warning(CStdOutStream *_so, const CCodecs *codecs, c
{
const CArcErrorInfo &er = arc.ErrorInfo;
UString s ("WARNING:\n");
s += arc.Path;
*_so << "WARNING:\n";
_so->NormalizePrint_UString(arc.Path);
UString s;
if (arc.FormatIndex == er.ErrorFormatIndex)
{
s.Add_LF();
@@ -619,7 +633,10 @@ HRESULT CExtractCallbackConsole::OpenResult(
{
*_se << endl;
if (level != 0)
*_se << arc.Path << endl;
{
_se->NormalizePrint_UString(arc.Path);
*_se << endl;
}
}
if (errorFlags != 0)
@@ -653,7 +670,10 @@ HRESULT CExtractCallbackConsole::OpenResult(
{
*_so << endl;
if (level != 0)
*_so << arc.Path << endl;
{
_so->NormalizePrint_UString(arc.Path);
*_so << endl;
}
}
if (warningFlags != 0)
@@ -708,7 +728,9 @@ HRESULT CExtractCallbackConsole::OpenResult(
_so->Flush();
if (_se)
{
*_se << kError << name << endl;
*_se << kError;
_se->NormalizePrint_wstr(name);
*_se << endl;
HRESULT res = Print_OpenArchive_Error(*_se, codecs, arcLink);
RINOK(res);
if (result == S_FALSE)

View File

@@ -269,7 +269,7 @@ HRESULT CHashCallbackConsole::SetOperationResult(UInt64 fileSize, const CHashBun
if (_fileName.IsEmpty())
*_so << kEmptyFileAlias;
else
*_so << _fileName;
_so->NormalizePrint_UString(_fileName);
}
*_so << endl;
}

View File

@@ -560,7 +560,7 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
{
if (!techMode)
g_StdOut << temp;
g_StdOut.PrintUString(FilePath, TempAString);
g_StdOut.NormalizePrint_UString(FilePath, TempWString, TempAString);
if (techMode)
g_StdOut << MY_ENDL;
continue;
@@ -671,9 +671,10 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
else if (prop.vt == VT_BSTR)
{
TempWString.SetFromBstr(prop.bstrVal);
// do we need multi-line support here ?
g_StdOut.Normalize_UString(TempWString);
if (techMode)
{
// replace CR/LF here.
g_StdOut.PrintUString(TempWString, TempAString);
}
else
@@ -815,9 +816,63 @@ static void PrintPropNameAndNumber_Signed(CStdOutStream &so, PROPID propID, Int6
so << val << endl;
}
static void PrintPropPair(CStdOutStream &so, const char *name, const wchar_t *val)
static void UString_Replace_CRLF_to_LF(UString &s)
{
so << name << " = " << val << endl;
// s.Replace(L"\r\n", L"\n");
wchar_t *src = s.GetBuf();
wchar_t *dest = src;
for (;;)
{
wchar_t c = *src++;
if (c == 0)
break;
if (c == '\r' && *src == '\n')
{
src++;
c = '\n';
}
*dest++ = c;
}
s.ReleaseBuf_SetEnd((unsigned)(dest - s.GetBuf()));
}
static void PrintPropVal_MultiLine(CStdOutStream &so, const wchar_t *val)
{
UString s = val;
if (s.Find(L'\n') >= 0)
{
so << endl;
so << "{";
so << endl;
UString_Replace_CRLF_to_LF(s);
so.Normalize_UString__LF_Allowed(s);
so << s;
so << endl;
so << "}";
}
else
{
so.Normalize_UString(s);
so << s;
}
so << endl;
}
static void PrintPropPair(CStdOutStream &so, const char *name, const wchar_t *val, bool multiLine)
{
so << name << " = ";
if (multiLine)
{
PrintPropVal_MultiLine(so, val);
return;
}
UString s = val;
so.Normalize_UString(s);
so << s;
so << endl;
}
@@ -831,9 +886,11 @@ static void PrintPropertyPair2(CStdOutStream &so, PROPID propID, const wchar_t *
UString nameU;
GetPropName(propID, name, nameA, nameU);
if (!nameA.IsEmpty())
PrintPropPair(so, nameA, s);
so << nameA;
else
so << nameU << " = " << s << endl;
so << nameU;
so << " = ";
PrintPropVal_MultiLine(so, s);
}
}
@@ -862,11 +919,11 @@ static void ErrorInfo_Print(CStdOutStream &so, const CArcErrorInfo &er)
{
PrintErrorFlags(so, "ERRORS:", er.GetErrorFlags());
if (!er.ErrorMessage.IsEmpty())
PrintPropPair(so, "ERROR", er.ErrorMessage);
PrintPropPair(so, "ERROR", er.ErrorMessage, true);
PrintErrorFlags(so, "WARNINGS:", er.GetWarningFlags());
if (!er.WarningMessage.IsEmpty())
PrintPropPair(so, "WARNING", er.WarningMessage);
PrintPropPair(so, "WARNING", er.WarningMessage, true);
}
HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const CArchiveLink &arcLink)
@@ -877,7 +934,7 @@ HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const
const CArcErrorInfo &er = arc.ErrorInfo;
so << "--\n";
PrintPropPair(so, "Path", arc.Path);
PrintPropPair(so, "Path", arc.Path, false);
if (er.ErrorFormatIndex >= 0)
{
if (er.ErrorFormatIndex == arc.FormatIndex)
@@ -885,7 +942,7 @@ HRESULT Print_OpenArchive_Props(CStdOutStream &so, const CCodecs *codecs, const
else
PrintArcTypeError(so, codecs->GetFormatNamePtr(er.ErrorFormatIndex), true);
}
PrintPropPair(so, "Type", codecs->GetFormatNamePtr(arc.FormatIndex));
PrintPropPair(so, "Type", codecs->GetFormatNamePtr(arc.FormatIndex), false);
ErrorInfo_Print(so, er);
@@ -943,7 +1000,8 @@ HRESULT Print_OpenArchive_Error(CStdOutStream &so, const CCodecs *codecs, const
{
if (arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
{
so << arcLink.NonOpen_ArcPath << endl;
so.NormalizePrint_UString(arcLink.NonOpen_ArcPath);
so << endl;
PrintArcTypeError(so, codecs->Formats[arcLink.NonOpen_ErrorInfo.ErrorFormatIndex].Name, false);
}
else
@@ -1014,15 +1072,18 @@ HRESULT ListArchives(CCodecs *codecs,
errorCode = ERROR_FILE_NOT_FOUND;
lastError = HRESULT_FROM_WIN32(lastError);;
g_StdOut.Flush();
*g_ErrStream << endl << kError << NError::MyFormatMessage(errorCode) <<
endl << arcPath << endl << endl;
*g_ErrStream << endl << kError << NError::MyFormatMessage(errorCode) << endl;
g_ErrStream->NormalizePrint_UString(arcPath);
*g_ErrStream << endl << endl;
numErrors++;
continue;
}
if (fi.IsDir())
{
g_StdOut.Flush();
*g_ErrStream << endl << kError << arcPath << " is not a file" << endl << endl;
*g_ErrStream << endl << kError;
g_ErrStream->NormalizePrint_UString(arcPath);
*g_ErrStream << " is not a file" << endl << endl;
numErrors++;
continue;
}
@@ -1061,7 +1122,9 @@ HRESULT ListArchives(CCodecs *codecs,
if (enableHeaders)
{
g_StdOut << endl << kListing << arcPath << endl << endl;
g_StdOut << endl << kListing;
g_StdOut.NormalizePrint_UString(arcPath);
g_StdOut << endl << endl;
}
HRESULT result = arcLink.Open_Strict(options, &openCallback);
@@ -1071,7 +1134,9 @@ HRESULT ListArchives(CCodecs *codecs,
if (result == E_ABORT)
return result;
g_StdOut.Flush();
*g_ErrStream << endl << kError << arcPath << " : ";
*g_ErrStream << endl << kError;
g_ErrStream->NormalizePrint_UString(arcPath);
*g_ErrStream << " : ";
if (result == S_FALSE)
{
Print_OpenArchive_Error(*g_ErrStream, codecs, arcLink);
@@ -1255,7 +1320,7 @@ HRESULT ListArchives(CCodecs *codecs,
if (arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
{
g_StdOut << "----------\n";
PrintPropPair(g_StdOut, "Path", arcLink.NonOpen_ArcPath);
PrintPropPair(g_StdOut, "Path", arcLink.NonOpen_ArcPath, false);
PrintArcTypeError(g_StdOut, codecs->Formats[arcLink.NonOpen_ErrorInfo.ErrorFormatIndex].Name, false);
}
}

View File

@@ -10,10 +10,6 @@
#include "../../../../C/CpuArch.h"
#if defined( _7ZIP_LARGE_PAGES)
#include "../../../../C/Alloc.h"
#endif
#include "../../../Common/MyInitGuid.h"
#include "../../../Common/CommandLineParser.h"
@@ -25,10 +21,6 @@
#include "../../../Windows/ErrorMsg.h"
#ifdef _WIN32
#include "../../../Windows/MemoryLock.h"
#endif
#include "../../../Windows/TimeUtils.h"
#include "../Common/ArchiveCommandLine.h"
@@ -64,7 +56,7 @@ using namespace NCommandLineParser;
HINSTANCE g_hInstance = 0;
#endif
bool g_LargePagesMode = false;
extern bool g_LargePagesMode;
extern CStdOutStream *g_StdStream;
extern CStdOutStream *g_ErrStream;
@@ -244,7 +236,8 @@ static void PrintWarningsPaths(const CErrorPathCodes &pc, CStdOutStream &so)
{
FOR_VECTOR(i, pc.Paths)
{
so << pc.Paths[i] << " : ";
so.NormalizePrint_UString(pc.Paths[i]);
so << " : ";
so << NError::MyFormatMessage(pc.Codes[i]) << endl;
}
so << "----------------" << endl;
@@ -383,6 +376,8 @@ static void PrintMemUsage(const char *s, UInt64 val)
*g_StdStream << " " << s << " Memory =";
PrintNum(SHIFT_SIZE_VALUE(val, 20), 7);
*g_StdStream << " MB";
if (g_LargePagesMode)
*g_StdStream << " (LP)";
}
EXTERN_C_BEGIN
@@ -524,6 +519,8 @@ int Main2(
parser.Parse1(commandStrings, options);
g_StdOut.IsTerminalMode = options.IsStdOutTerminal;
g_StdErr.IsTerminalMode = options.IsStdErrTerminal;
if (options.Number_for_Out != k_OutStream_stdout)
g_StdStream = (options.Number_for_Out == k_OutStream_stderr ? &g_StdErr : NULL);
@@ -541,24 +538,6 @@ int Main2(
return 0;
}
#if defined(_WIN32) && !defined(UNDER_CE)
NSecurity::EnablePrivilege_SymLink();
#endif
#ifdef _7ZIP_LARGE_PAGES
if (options.LargePages)
{
SetLargePageSize();
// note: this process also can inherit that Privilege from parent process
g_LargePagesMode =
#if defined(_WIN32) && !defined(UNDER_CE)
NSecurity::EnablePrivilege_LockMemory();
#else
true;
#endif
}
#endif
if (options.EnableHeaders)
ShowCopyrightAndHelp(g_StdStream, false);

View File

@@ -79,7 +79,7 @@ int MY_CDECL main
PrintError(kUserBreakMessage);
return (NExitCode::kUserBreak);
}
catch(const CArcCmdLineException &e)
catch(const CMessagePathException &e)
{
PrintError(kException_CmdLine_Error_Message);
if (g_ErrStream)

View File

@@ -141,8 +141,9 @@ void CPercentPrinter::Print()
{
_s += ' ';
StdOut_Convert_UString_to_AString(FileName, _temp);
_temp.Replace('\n', ' ');
_tempU = FileName;
_so->Normalize_UString(_tempU);
StdOut_Convert_UString_to_AString(_tempU, _temp);
if (_s.Len() + _temp.Len() > MaxLen)
{
unsigned len = FileName.Len();
@@ -153,8 +154,9 @@ void CPercentPrinter::Print()
delta = 1;
len -= delta;
_tempU = FileName;
_tempU.Delete(len / 2, FileName.Len() - len);
_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;

View File

@@ -143,7 +143,9 @@ HRESULT CUpdateCallbackConsole::OpenResult(
_so->Flush();
if (_se)
{
*_se << kError << name << endl;
*_se << kError;
_se->NormalizePrint_wstr(name);
*_se << endl;
HRESULT res = Print_OpenArchive_Error(*_se, codecs, arcLink);
RINOK(res);
_se->Flush();
@@ -185,7 +187,9 @@ void CCallbackConsoleBase::CommonError(const FString &path, DWORD systemError, b
*_se << endl << (isWarning ? kWarning : kError)
<< NError::MyFormatMessage(systemError)
<< endl << fs2us(path) << endl << endl;
<< endl;
_se->NormalizePrint_UString(fs2us(path));
*_se << endl << endl;
_se->Flush();
}
}
@@ -281,8 +285,8 @@ HRESULT CUpdateCallbackConsole::StartArchive(const wchar_t *name, bool updating)
if (_so)
{
*_so << (updating ? kUpdatingArchiveMessage : kCreatingArchiveMessage);
if (name != 0)
*_so << name;
if (name)
_so->NormalizePrint_wstr(name);
else
*_so << k_StdOut_ArcName;
*_so << endl << endl;
@@ -343,6 +347,7 @@ HRESULT CUpdateCallbackConsole::DeletingAfterArchiving(const FString &path, bool
_tempA.Add_Space();
*_so << _tempA;
_tempU = fs2us(path);
_so->Normalize_UString(_tempU);
_so->PrintUString(_tempU, _tempA);
*_so << endl;
if (NeedFlush)
@@ -475,7 +480,10 @@ HRESULT CCallbackConsoleBase::PrintProgress(const wchar_t *name, const char *com
_tempU.Empty();
if (name)
{
_tempU = name;
_so->Normalize_UString(_tempU);
}
_so->PrintUString(_tempU, _tempA);
*_so << endl;
if (NeedFlush)
@@ -568,7 +576,9 @@ HRESULT CUpdateCallbackConsole::ReportExtractResult(Int32 opRes, Int32 isEncrypt
AString s;
SetExtractErrorMessage(opRes, isEncrypted, s);
*_se << s << " : " << endl << name << endl << endl;
*_se << s << " : " << endl;
_se->NormalizePrint_wstr(name);
*_se << endl << endl;
_se->Flush();
}
return S_OK;

View File

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