This commit is contained in:
Igor Pavlov
2017-04-30 00:00:00 +00:00
committed by Kornel
parent 603abd5528
commit 2efa10565a
442 changed files with 15479 additions and 8525 deletions

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;
}