Update to 7-Zip 17.00 Beta

This commit is contained in:
Tino Reichardt
2017-04-30 14:14:14 +02:00
parent 54389d6e2f
commit aa5ba75da0
451 changed files with 15746 additions and 8574 deletions

View File

@@ -44,7 +44,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /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" /FAs /Yu"StdAfx.h" /FD /GF /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

View File

@@ -32,7 +32,7 @@ static HRESULT CheckBreak2()
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
}
static const char *kError = "ERROR: ";
static const char * const kError = "ERROR: ";
void CExtractScanConsole::StartScanning()
@@ -138,33 +138,33 @@ static NSynchronization::CCriticalSection g_CriticalSection;
#endif
static const char *kTestString = "T";
static const char *kExtractString = "-";
static const char *kSkipString = ".";
static const char * const kTestString = "T";
static const char * const kExtractString = "-";
static const char * const kSkipString = ".";
// static const char *kCantAutoRename = "can not create file with auto name\n";
// static const char *kCantRenameFile = "can not rename existing file\n";
// static const char *kCantDeleteOutputFile = "can not delete output file ";
// 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 *kMemoryExceptionMessage = "Can't allocate required memory!";
static const char * const kMemoryExceptionMessage = "Can't allocate required memory!";
static const char *kExtracting = "Extracting archive: ";
static const char *kTesting = "Testing archive: ";
static const char * const kExtracting = "Extracting archive: ";
static const char * const kTesting = "Testing archive: ";
static const char *kEverythingIsOk = "Everything is Ok";
static const char *kNoFiles = "No files to process";
static const char * const kEverythingIsOk = "Everything is Ok";
static const char * const kNoFiles = "No files to process";
static const char *kUnsupportedMethod = "Unsupported Method";
static const char *kCrcFailed = "CRC Failed";
static const char *kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
static const char *kDataError = "Data Error";
static const char *kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
static const char *kUnavailableData = "Unavailable data";
static const char *kUnexpectedEnd = "Unexpected end of data";
static const char *kDataAfterEnd = "There are some data after the end of the payload data";
static const char *kIsNotArc = "Is not archive";
static const char *kHeadersError = "Headers Error";
static const char *kWrongPassword = "Wrong password";
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[] =
{
@@ -206,7 +206,7 @@ STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *completeValue)
return CheckBreak2();
}
static const char *kTab = " ";
static const char * const kTab = " ";
static void PrintFileInfo(CStdOutStream *_so, const wchar_t *path, const FILETIME *ft, const UInt64 *size)
{
@@ -220,10 +220,8 @@ static void PrintFileInfo(CStdOutStream *_so, const wchar_t *path, const FILETIM
if (ft)
{
char temp[64];
FILETIME locTime;
if (FileTimeToLocalFileTime(ft, &locTime))
if (ConvertFileTimeToString(locTime, temp, true, true))
*_so << kTab << "Modified: " << temp << endl;
if (ConvertUtcFileTimeToString(*ft, temp, kTimestampPrintLevel_SEC))
*_so << kTab << "Modified: " << temp << endl;
}
}
@@ -256,6 +254,8 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
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;
}
@@ -388,10 +388,8 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &dest)
dest += s;
else
{
char temp[16];
ConvertUInt32ToString(opRes, temp);
dest += "Error #";
dest += temp;
dest.Add_UInt32(opRes);
}
}
@@ -524,22 +522,22 @@ void PrintErrorFlags(CStdOutStream &so, const char *s, UInt32 errorFlags)
void Add_Messsage_Pre_ArcType(UString &s, const char *pre, const wchar_t *arcType)
{
s.Add_LF();
s.AddAscii(pre);
s.AddAscii(" as [");
s += pre;
s += " as [";
s += arcType;
s.AddAscii("] archive");
s += "] archive";
}
void Print_ErrorFormatIndex_Warning(CStdOutStream *_so, const CCodecs *codecs, const CArc &arc)
{
const CArcErrorInfo &er = arc.ErrorInfo;
UString s = L"WARNING:\n";
UString s ("WARNING:\n");
s += arc.Path;
if (arc.FormatIndex == er.ErrorFormatIndex)
{
s.Add_LF();
s.AddAscii("The archive is open with offset");
s += "The archive is open with offset";
}
else
{

View File

@@ -7,9 +7,9 @@
#include "ConsoleClose.h"
#include "HashCon.h"
static const wchar_t *kEmptyFileAlias = L"[Content]";
static const char * const kEmptyFileAlias = "[Content]";
static const char *kScanningMessage = "Scanning";
static const char * const kScanningMessage = "Scanning";
static HRESULT CheckBreak2()
{
@@ -168,7 +168,7 @@ HRESULT CHashCallbackConsole::BeforeFirstFile(const CHashBundle &hb)
if (PrintSize)
{
_s.Add_Space();
const AString s2 = "Size";
const AString s2 ("Size");
AddSpaces_if_Positive(_s, (int)kSizeField_Len - (int)s2.Len());
_s += s2;
}

View File

@@ -128,14 +128,14 @@ static const char * const kPropIdToName[] =
static const char kEmptyAttribChar = '.';
static const char *kListing = "Listing archive: ";
static const char * const kListing = "Listing archive: ";
static const char *kString_Files = "files";
static const char *kString_Dirs = "folders";
static const char *kString_AltStreams = "alternate streams";
static const char *kString_Streams = "streams";
static const char * const kString_Files = "files";
static const char * const kString_Dirs = "folders";
static const char * const kString_AltStreams = "alternate streams";
static const char * const kString_Streams = "streams";
static const char *kError = "ERROR: ";
static const char * const kError = "ERROR: ";
static void GetAttribString(UInt32 wa, bool isDir, bool allAttribs, char *s)
{
@@ -417,9 +417,8 @@ static void GetPropName(PROPID propID, const wchar_t *name, AString &nameA, UStr
nameU = name;
else
{
char s[16];
ConvertUInt32ToString(propID, s);
nameA = s;
nameA.Empty();
nameA.Add_UInt32(propID);
}
}
@@ -429,7 +428,7 @@ void CFieldPrinter::AddProp(const wchar_t *name, PROPID propID, bool isRawProp)
f.PropID = propID;
f.IsRawProp = isRawProp;
GetPropName(propID, name, f.NameA, f.NameU);
f.NameU.AddAscii(" = ");
f.NameU += " = ";
if (!f.NameA.IsEmpty())
f.NameA += " = ";
else
@@ -499,10 +498,7 @@ static void PrintTime(char *dest, const FILETIME *ft)
*dest = 0;
if (ft->dwLowDateTime == 0 && ft->dwHighDateTime == 0)
return;
FILETIME locTime;
if (!FileTimeToLocalFileTime(ft, &locTime))
throw 20121211;
ConvertFileTimeToString(locTime, dest, true, true);
ConvertUtcFileTimeToString(*ft, dest, kTimestampPrintLevel_SEC);
}
#ifndef _SFX
@@ -686,7 +682,7 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
else
{
char s[64];
ConvertPropertyToShortString(s, prop, f.PropID);
ConvertPropertyToShortString2(s, prop, f.PropID);
if (techMode)
g_StdOut << s;
else
@@ -828,7 +824,7 @@ static void PrintPropPair(CStdOutStream &so, const char *name, const wchar_t *va
static void PrintPropertyPair2(CStdOutStream &so, PROPID propID, const wchar_t *name, const CPropVariant &prop)
{
UString s;
ConvertPropertyToString(s, prop, propID);
ConvertPropertyToString2(s, prop, propID);
if (!s.IsEmpty())
{
AString nameA;

View File

@@ -64,6 +64,8 @@ using namespace NCommandLineParser;
HINSTANCE g_hInstance = 0;
#endif
bool g_LargePagesMode = false;
extern CStdOutStream *g_StdStream;
extern CStdOutStream *g_ErrStream;
@@ -73,24 +75,19 @@ extern const CCodecInfo *g_Codecs[];
extern unsigned g_NumHashers;
extern const CHasherInfo *g_Hashers[];
static const char *kCopyrightString = "\n7-Zip"
#ifndef EXTERNAL_CODECS
#ifdef PROG_VARIANT_R
" (r)"
#else
" (a)"
#endif
#endif
static const char * const kCopyrightString = "\n7-Zip"
#ifndef EXTERNAL_CODECS
#ifdef PROG_VARIANT_R
" (r)"
#else
" (a)"
#endif
#endif
#ifdef MY_CPU_64BIT
" [64]"
#elif defined MY_CPU_32BIT
" [32]"
#endif
" " MY_VERSION_CPU
" : " MY_COPYRIGHT_DATE "\n\n";
" " MY_VERSION_COPYRIGHT_DATE "\n\n";
static const char *kHelpString =
static const char * const kHelpString =
"Usage: 7z"
#ifndef EXTERNAL_CODECS
#ifdef PROG_VARIANT_R
@@ -128,6 +125,7 @@ static const char *kHelpString =
" -i[r[-|0]]{@listfile|!wildcard} : Include filenames\n"
" -m{Parameters} : set compression Method\n"
" -mmt[N] : set number of CPU threads\n"
" -mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)\n"
" -o{Directory} : set Output directory\n"
#ifndef _NO_CRYPTO
" -p{Password} : set Password\n"
@@ -166,13 +164,13 @@ static const char *kHelpString =
// ---------------------------
// exception messages
static const char *kEverythingIsOk = "Everything is Ok";
static const char *kUserErrorMessage = "Incorrect command line";
static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
static const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
// static const char *kUnsupportedUpdateArcType = "Can't create archive for that type";
static const char * const kEverythingIsOk = "Everything is Ok";
static const char * const kUserErrorMessage = "Incorrect command line";
static const char * const kNoFormats = "7-Zip cannot find the code that works with archives.";
static const char * const kUnsupportedArcTypeMessage = "Unsupported archive type";
// static const char * const kUnsupportedUpdateArcType = "Can't create archive for that type";
static CFSTR kDefaultSfxModule = FTEXT("7zCon.sfx");
#define kDefaultSfxModule "7zCon.sfx"
static void ShowMessageAndThrowException(LPCSTR message, NExitCode::EEnum code)
{
@@ -204,9 +202,9 @@ static void ShowCopyrightAndHelp(CStdOutStream *so, bool needHelp)
}
static void PrintStringRight(CStdOutStream &so, const AString &s, unsigned size)
static void PrintStringRight(CStdOutStream &so, const char *s, unsigned size)
{
unsigned len = s.Len();
unsigned len = MyStringLen(s);
for (unsigned i = len; i < size; i++)
so << ' ';
so << s;
@@ -279,7 +277,7 @@ static int WarningsCheck(HRESULT result, const CCallbackConsoleBase &callback,
UString message;
if (!errorInfo.Message.IsEmpty())
{
message.AddAscii(errorInfo.Message);
message += errorInfo.Message.Ptr();
message.Add_LF();
}
{
@@ -389,6 +387,7 @@ static void PrintMemUsage(const char *s, UInt64 val)
EXTERN_C_BEGIN
typedef BOOL (WINAPI *Func_GetProcessMemoryInfo)(HANDLE Process,
PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb);
typedef BOOL (WINAPI *Func_QueryProcessCycleTime)(HANDLE Process, PULONG64 CycleTime);
EXTERN_C_END
#endif
@@ -415,6 +414,8 @@ static void PrintStat()
PROCESS_MEMORY_COUNTERS m;
memset(&m, 0, sizeof(m));
BOOL memDefined = FALSE;
BOOL cycleDefined = FALSE;
ULONG64 cycleTime = 0;
{
/* NT 4.0: GetProcessMemoryInfo() in Psapi.dll
Win7: new function K32GetProcessMemoryInfo() in kernel32.dll
@@ -425,8 +426,9 @@ static void PrintStat()
// memDefined = GetProcessMemoryInfo(GetCurrentProcess(), &m, sizeof(m));
*/
HMODULE kern = ::GetModuleHandleW(L"kernel32.dll");
Func_GetProcessMemoryInfo my_GetProcessMemoryInfo = (Func_GetProcessMemoryInfo)
::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), "K32GetProcessMemoryInfo");
::GetProcAddress(kern, "K32GetProcessMemoryInfo");
if (!my_GetProcessMemoryInfo)
{
HMODULE lib = LoadLibraryW(L"Psapi.dll");
@@ -436,6 +438,11 @@ static void PrintStat()
if (my_GetProcessMemoryInfo)
memDefined = my_GetProcessMemoryInfo(GetCurrentProcess(), &m, sizeof(m));
// FreeLibrary(lib);
Func_QueryProcessCycleTime my_QueryProcessCycleTime = (Func_QueryProcessCycleTime)
::GetProcAddress(kern, "QueryProcessCycleTime");
if (my_QueryProcessCycleTime)
cycleDefined = my_QueryProcessCycleTime(GetCurrentProcess(), &cycleTime);
}
#endif
@@ -448,6 +455,16 @@ static void PrintStat()
UInt64 totalTime = curTime - creationTime;
PrintTime("Kernel ", kernelTime, totalTime);
#ifndef UNDER_CE
if (cycleDefined)
{
*g_StdStream << " ";
PrintNum(cycleTime / 1000000, 22);
*g_StdStream << " MCycles";
}
#endif
PrintTime("User ", userTime, totalTime);
PrintTime("Process", kernelTime + userTime, totalTime);
@@ -470,6 +487,7 @@ static void PrintHexId(CStdOutStream &so, UInt64 id)
PrintStringRight(so, s, 8);
}
int Main2(
#ifndef _WIN32
int numArgs, char *args[]
@@ -488,14 +506,17 @@ int Main2(
GetArguments(numArgs, args, commandStrings);
#endif
if (commandStrings.Size() == 1)
#ifndef UNDER_CE
if (commandStrings.Size() > 0)
commandStrings.Delete(0);
#endif
if (commandStrings.Size() == 0)
{
ShowCopyrightAndHelp(g_StdStream, true);
return 0;
}
commandStrings.Delete(0);
CArcCmdLineOptions options;
CArcCmdLineParser parser;
@@ -527,8 +548,11 @@ int Main2(
if (options.LargePages)
{
SetLargePageSize();
g_LargePagesMode =
#if defined(_WIN32) && !defined(UNDER_CE)
NSecurity::EnablePrivilege_LockMemory();
NSecurity::EnablePrivilege_LockMemory();
#else
true;
#endif
}
#endif
@@ -579,7 +603,7 @@ int Main2(
#ifdef EXTERNAL_CODECS
if (!codecs->MainDll_ErrorPath.IsEmpty())
{
UString s = L"Can't load module ";
UString s ("Can't load module: ");
s += fs2us(codecs->MainDll_ErrorPath);
throw s;
}
@@ -639,7 +663,7 @@ int Main2(
so << endl << "Formats:" << endl;
const char *kArcFlags = "KSNFMGOPBELH";
const char * const kArcFlags = "KSNFMGOPBELH";
const unsigned kNumArcFlags = (unsigned)strlen(kArcFlags);
for (i = 0; i < codecs->Formats.Size(); i++)
@@ -673,9 +697,9 @@ int Main2(
s += ext.Ext;
if (!ext.AddExt.IsEmpty())
{
s += L" (";
s += " (";
s += ext.AddExt;
s += L')';
s += ')';
}
}

View File

@@ -24,12 +24,12 @@ extern int Main2(
#endif
);
static const char *kException_CmdLine_Error_Message = "Command Line Error:";
static const char *kExceptionErrorMessage = "ERROR:";
static const char *kUserBreakMessage = "Break signaled";
static const char *kMemoryExceptionMessage = "ERROR: Can't allocate required memory!";
static const char *kUnknownExceptionMessage = "Unknown Error";
static const char *kInternalExceptionMessage = "\n\nInternal Error #";
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()
{

View File

@@ -32,13 +32,17 @@ HRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *files, const UInt64 *b
if (bytes)
{
_totalBytesDefined = true;
// _totalBytes = *bytes;
// _totalBytesDefined = true;
_totalBytes = *bytes;
if (!files)
_percent.Total = *bytes;
}
else
_totalBytesDefined = false;
{
// _totalBytesDefined = false;
if (!files)
_percent.Total = _totalBytes;
}
}
return CheckBreak2();
@@ -83,7 +87,7 @@ HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
ClosePercents();
Password = GetPassword(_so);
RINOK(GetPassword_HRESULT(_so, Password));
PasswordIsDefined = true;
}
return StringToBstr(Password, password);

View File

@@ -18,9 +18,9 @@ protected:
CStdOutStream *_se;
bool _totalFilesDefined;
bool _totalBytesDefined;
// bool _totalBytesDefined;
// UInt64 _totalFiles;
// UInt64 _totalBytes;
UInt64 _totalBytes;
bool NeedPercents() const { return _percent._so != NULL; }
@@ -36,7 +36,8 @@ public:
COpenCallbackConsole():
_totalFilesDefined(false),
_totalBytesDefined(false),
// _totalBytesDefined(false),
_totalBytes(0),
MultiArcMode(false)
#ifndef _NO_CRYPTO

View File

@@ -23,15 +23,15 @@ static NSynchronization::CCriticalSection g_CriticalSection;
#define MT_LOCK
#endif
static const wchar_t *kEmptyFileAlias = L"[Content]";
static const wchar_t * const kEmptyFileAlias = L"[Content]";
static const char *kOpenArchiveMessage = "Open archive: ";
static const char *kCreatingArchiveMessage = "Creating archive: ";
static const char *kUpdatingArchiveMessage = "Updating archive: ";
static const char *kScanningMessage = "Scanning the drive:";
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 *kError = "ERROR: ";
static const char *kWarning = "WARNING: ";
static const char * const kError = "ERROR: ";
static const char * const kWarning = "WARNING: ";
static HRESULT CheckBreak2()
{
@@ -259,7 +259,7 @@ HRESULT CUpdateCallbackConsole::FinishScanning(const CDirItemsStat &st)
return S_OK;
}
static const char *k_StdOut_ArcName = "StdOut";
static const char * const k_StdOut_ArcName = "StdOut";
HRESULT CUpdateCallbackConsole::StartOpenArchive(const wchar_t *name)
{
@@ -316,7 +316,7 @@ HRESULT CUpdateCallbackConsole::WriteSfx(const wchar_t *name, UInt64 size)
{
*_so << "Write SFX: ";
*_so << name;
AString s = " : ";
AString s (" : ");
PrintSize_bytes_Smart(s, size);
*_so << s << endl;
}
@@ -398,14 +398,31 @@ HRESULT CUpdateCallbackConsole::Finalize()
}
*/
HRESULT CUpdateCallbackConsole::SetNumItems(UInt64 numItems)
void static PrintToDoStat(CStdOutStream *_so, const CDirItemsStat &stat, const char *name)
{
AString s;
Print_DirItemsStat(s, stat);
*_so << name << ": " << s << endl;
}
HRESULT CUpdateCallbackConsole::SetNumItems(const CArcToDoStat &stat)
{
if (_so)
{
ClosePercents_for_so();
AString s;
PrintPropPair(s, "Items to compress", numItems);
*_so << s << endl << endl;
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;
}
@@ -622,7 +639,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
{
if (AskPassword)
{
Password = GetPassword(_so);
RINOK(GetPassword_HRESULT(_so, Password));
PasswordIsDefined = true;
}
}
@@ -649,7 +666,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
{
Password = GetPassword(_so);
RINOK(GetPassword_HRESULT(_so, Password))
PasswordIsDefined = true;
}
}

View File

@@ -14,8 +14,8 @@ static const char kNoAll = 's';
static const char kAutoRenameAll = 'u';
static const char kQuit = 'q';
static const char *kFirstQuestionMessage = "? ";
static const char *kHelpQuestionMessage =
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;
@@ -31,9 +31,16 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
*outStream << kHelpQuestionMessage;
outStream->Flush();
}
AString scannedString = g_StdIn.ScanStringUntilNewLine();
AString scannedString;
if (!g_StdIn.ScanAStringUntilNewLine(scannedString))
return NUserAnswerMode::kError;
if (g_StdIn.Error())
return NUserAnswerMode::kError;
scannedString.Trim();
if (!scannedString.IsEmpty())
if (scannedString.IsEmpty() && g_StdIn.Eof())
return NUserAnswerMode::kEof;
if (scannedString.Len() == 1)
switch (::MyCharLower_Ascii(scannedString[0]))
{
case kYes: return NUserAnswerMode::kYes;
@@ -52,7 +59,7 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
#endif
#endif
UString GetPassword(CStdOutStream *outStream)
static bool GetPassword(CStdOutStream *outStream, UString &psw)
{
if (outStream)
{
@@ -72,19 +79,32 @@ UString GetPassword(CStdOutStream *outStream)
if (console != INVALID_HANDLE_VALUE && console != 0)
if (GetConsoleMode(console, &mode))
wasChanged = (SetConsoleMode(console, mode & ~ENABLE_ECHO_INPUT) != 0);
UString res = g_StdIn.ScanUStringUntilNewLine();
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;
#else
return g_StdIn.ScanUStringUntilNewLine();
#endif
}
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw)
{
if (!GetPassword(outStream, psw))
return E_INVALIDARG;
if (g_StdIn.Error())
return E_FAIL;
if (g_StdIn.Eof() && psw.IsEmpty())
return E_ABORT;
return S_OK;
}

View File

@@ -14,11 +14,14 @@ enum EEnum
kYesAll,
kNoAll,
kAutoRenameAll,
kQuit
kQuit,
kEof,
kError
};
}
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream);
UString GetPassword(CStdOutStream *outStream);
// bool GetPassword(CStdOutStream *outStream, UString &psw);
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw);
#endif

View File

@@ -1,3 +1,3 @@
#include "../../MyVersionInfo.rc"
MY_VERSION_INFO_APP("7-Zip Console", "7z")
MY_VERSION_INFO_APP("7-Zip Console" , "7z")