mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 12:24:48 +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),
|
NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
(LPTSTR)&szError, 0, NULL))
|
(LPTSTR)&szError, 0, NULL))
|
||||||
{
|
{
|
||||||
ConErrPrintf(_T("%s %s\n"), szError, szMessage);
|
ConErrPrintf(_T("%s%s%s"), szError, szMessage, (*szMessage ? _T("\n") : _T("")));
|
||||||
if (szError)
|
if (szError)
|
||||||
LocalFree(szError);
|
LocalFree(szError);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -327,6 +327,8 @@ INT cmd_mkdir (LPTSTR param)
|
||||||
{
|
{
|
||||||
LPTSTR *p;
|
LPTSTR *p;
|
||||||
INT argc, i;
|
INT argc, i;
|
||||||
|
DWORD dwLastError;
|
||||||
|
|
||||||
if (!_tcsncmp (param, _T("/?"), 2))
|
if (!_tcsncmp (param, _T("/?"), 2))
|
||||||
{
|
{
|
||||||
ConOutResPaging(TRUE,STRING_MKDIR_HELP);
|
ConOutResPaging(TRUE,STRING_MKDIR_HELP);
|
||||||
|
@ -347,13 +349,20 @@ INT cmd_mkdir (LPTSTR param)
|
||||||
{
|
{
|
||||||
if (!MakeFullPath(p[i]))
|
if (!MakeFullPath(p[i]))
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_PATH_NOT_FOUND)
|
dwLastError = GetLastError();
|
||||||
|
switch (dwLastError)
|
||||||
{
|
{
|
||||||
|
case ERROR_PATH_NOT_FOUND:
|
||||||
ConErrResPuts(STRING_MD_ERROR2);
|
ConErrResPuts(STRING_MD_ERROR2);
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
case ERROR_FILE_EXISTS:
|
||||||
ErrorMessage (GetLastError(), _T("MD"));
|
case ERROR_ALREADY_EXISTS:
|
||||||
|
ConErrResPrintf(STRING_MD_ERROR, p[i]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ErrorMessage(GetLastError(), NULL);
|
||||||
}
|
}
|
||||||
nErrorLevel = 1;
|
nErrorLevel = 1;
|
||||||
}
|
}
|
||||||
|
@ -504,7 +513,7 @@ INT cmd_rmdir(LPTSTR param)
|
||||||
{
|
{
|
||||||
/* Couldn't delete the folder, print out the error */
|
/* Couldn't delete the folder, print out the error */
|
||||||
nError = GetLastError();
|
nError = GetLastError();
|
||||||
ErrorMessage(nError, _T("RD"));
|
ErrorMessage(nError, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue