mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 12:29:56 +00:00
[CMD] Improve the way the ErrorMessage() helper and the MKDIR and RMDIR commands report their errors.
For MKDIR, also properly support the case of ERROR_FILE_EXISTS and ERROR_ALREADY_EXISTS last-errors by displaying the standard error "A subdirectory or file XXX already exists.\n"
This commit is contained in:
parent
1efbcd3d5d
commit
5830ccb85e
2 changed files with 16 additions and 7 deletions
|
@ -50,7 +50,7 @@ ErrorMessage(
|
|||
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&szError, 0, NULL))
|
||||
{
|
||||
ConErrPrintf(_T("%s %s\n"), szError, szMessage);
|
||||
ConErrPrintf(_T("%s%s%s"), szError, szMessage, (*szMessage ? _T("\n") : _T("")));
|
||||
if (szError)
|
||||
LocalFree(szError);
|
||||
return;
|
||||
|
|
|
@ -327,6 +327,8 @@ INT cmd_mkdir (LPTSTR param)
|
|||
{
|
||||
LPTSTR *p;
|
||||
INT argc, i;
|
||||
DWORD dwLastError;
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
ConOutResPaging(TRUE,STRING_MKDIR_HELP);
|
||||
|
@ -347,13 +349,20 @@ INT cmd_mkdir (LPTSTR param)
|
|||
{
|
||||
if (!MakeFullPath(p[i]))
|
||||
{
|
||||
if (GetLastError() == ERROR_PATH_NOT_FOUND)
|
||||
dwLastError = GetLastError();
|
||||
switch (dwLastError)
|
||||
{
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
ConErrResPuts(STRING_MD_ERROR2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessage (GetLastError(), _T("MD"));
|
||||
break;
|
||||
|
||||
case ERROR_FILE_EXISTS:
|
||||
case ERROR_ALREADY_EXISTS:
|
||||
ConErrResPrintf(STRING_MD_ERROR, p[i]);
|
||||
break;
|
||||
|
||||
default:
|
||||
ErrorMessage(GetLastError(), NULL);
|
||||
}
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
@ -504,7 +513,7 @@ INT cmd_rmdir(LPTSTR param)
|
|||
{
|
||||
/* Couldn't delete the folder, print out the error */
|
||||
nError = GetLastError();
|
||||
ErrorMessage(nError, _T("RD"));
|
||||
ErrorMessage(nError, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue