add ConErrMessage to deal with error msg and ConOutMessage for other msg. Copy error msg are always pipe with ConOut and CD error msg with ConErr. Thx harmut that remmid me about it. All error msg need to check if they goes with ConErr or ConOut

svn path=/trunk/; revision=16651
This commit is contained in:
Magnus Olsen 2005-07-19 22:48:35 +00:00
parent 73e69c9d9e
commit 6e7d8b2e8d
3 changed files with 33 additions and 3 deletions

View file

@ -152,6 +152,7 @@ VOID ConErrChar (TCHAR);
VOID ConErrPuts (LPTSTR);
VOID ConErrPrintf (LPTSTR, ...);
VOID ConOutFormatMessage (DWORD MessageId, ...);
VOID ConErrFormatMessage (DWORD MessageId, ...);
SHORT GetCursorX (VOID);
SHORT GetCursorY (VOID);

View file

@ -330,6 +330,35 @@ VOID ConPrintfPaging(BOOL NewPage, LPTSTR szFormat, va_list arg_ptr, DWORD nStdH
#endif
}
VOID ConErrFormatMessage (DWORD MessageId, ...)
{
TCHAR szMsg[RC_STRING_MAX_SIZE];
DWORD ret;
LPTSTR text;
va_list arg_ptr;
va_start (arg_ptr, MessageId);
ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
MessageId,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &text,
0,
&arg_ptr);
va_end (arg_ptr);
if(ret > 0)
{
ConErrPuts (text);
LocalFree(text);
}
else
{
LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE);
ConErrPrintf(szMsg);
}
}
VOID ConOutFormatMessage (DWORD MessageId, ...)
{
TCHAR szMsg[RC_STRING_MAX_SIZE];
@ -349,13 +378,13 @@ VOID ConOutFormatMessage (DWORD MessageId, ...)
va_end (arg_ptr);
if(ret > 0)
{
ConOutPuts (text);
ConErrPuts (text);
LocalFree(text);
}
else
{
LoadString(CMD_ModuleHandle, STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE);
ConOutPrintf(szMsg);
ConErrPrintf(szMsg);
}
}

View file

@ -364,7 +364,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
{
if(hFile == INVALID_HANDLE_VALUE)
{
ConOutFormatMessage (GetLastError(), szFinalPath);
ConErrFormatMessage (GetLastError(), szFinalPath);
nErrorLevel = 1;
return 1;
}