mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 05:26:58 +00:00
[CMD] MOVE: Set the errorlevel on failure.
CORE-14261
This commit is contained in:
parent
ae649656db
commit
3b960a1c21
|
@ -158,16 +158,16 @@ INT cmd_move (LPTSTR param)
|
||||||
{
|
{
|
||||||
/* there must be at least one pathspec */
|
/* there must be at least one pathspec */
|
||||||
error_req_param_missing();
|
error_req_param_missing();
|
||||||
freep(arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nFiles > 2)
|
if (nFiles > 2)
|
||||||
{
|
{
|
||||||
/* there are more than two pathspecs */
|
/* there are more than two pathspecs */
|
||||||
error_too_many_parameters(param);
|
error_too_many_parameters(param);
|
||||||
freep(arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no destination is given, default to current directory */
|
/* If no destination is given, default to current directory */
|
||||||
|
@ -178,8 +178,8 @@ INT cmd_move (LPTSTR param)
|
||||||
{
|
{
|
||||||
/* '*'/'?' in dest, this doesnt happen. give folder name instead*/
|
/* '*'/'?' in dest, this doesnt happen. give folder name instead*/
|
||||||
error_invalid_parameter_format(pszDest);
|
error_invalid_parameter_format(pszDest);
|
||||||
freep(arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
if (_tcschr(arg[i], _T('*')) != NULL || _tcschr(arg[i], _T('?')) != NULL)
|
if (_tcschr(arg[i], _T('*')) != NULL || _tcschr(arg[i], _T('?')) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -199,9 +199,9 @@ INT cmd_move (LPTSTR param)
|
||||||
hFile = FindFirstFile (arg[i], &findBuffer);
|
hFile = FindFirstFile (arg[i], &findBuffer);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
ErrorMessage (GetLastError (), arg[i]);
|
ErrorMessage(GetLastError(), arg[i]);
|
||||||
freep (arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for special cases "." and ".." and if found skip them */
|
/* check for special cases "." and ".." and if found skip them */
|
||||||
|
@ -216,8 +216,8 @@ INT cmd_move (LPTSTR param)
|
||||||
/* what? we don't have anything to move? */
|
/* what? we don't have anything to move? */
|
||||||
error_file_not_found();
|
error_file_not_found();
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
freep(arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnlyOneFile = TRUE;
|
OnlyOneFile = TRUE;
|
||||||
|
@ -247,9 +247,9 @@ INT cmd_move (LPTSTR param)
|
||||||
hFile = FindFirstFile (arg[i], &findBuffer);
|
hFile = FindFirstFile (arg[i], &findBuffer);
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
ErrorMessage (GetLastError (), arg[i]);
|
ErrorMessage(GetLastError(), arg[i]);
|
||||||
freep (arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for special cases "." and ".." and if found skip them */
|
/* check for special cases "." and ".." and if found skip them */
|
||||||
|
@ -264,8 +264,8 @@ INT cmd_move (LPTSTR param)
|
||||||
/* huh? somebody removed files and/or folders which were there */
|
/* huh? somebody removed files and/or folders which were there */
|
||||||
error_file_not_found();
|
error_file_not_found();
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
freep(arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if source and destination paths are on different volumes */
|
/* check if source and destination paths are on different volumes */
|
||||||
|
@ -340,8 +340,8 @@ INT cmd_move (LPTSTR param)
|
||||||
/* We are not allowed to have existing source and destination dir when there is wildcard in source */
|
/* We are not allowed to have existing source and destination dir when there is wildcard in source */
|
||||||
error_syntax(NULL);
|
error_syntax(NULL);
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
freep(arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
if (!(dwMoveStatusFlags & (MOVE_DEST_IS_FILE | MOVE_DEST_IS_DIR)))
|
if (!(dwMoveStatusFlags & (MOVE_DEST_IS_FILE | MOVE_DEST_IS_DIR)))
|
||||||
{
|
{
|
||||||
|
@ -360,8 +360,8 @@ INT cmd_move (LPTSTR param)
|
||||||
/*source has many files but there is only one destination file*/
|
/*source has many files but there is only one destination file*/
|
||||||
error_invalid_parameter_format(pszDest);
|
error_invalid_parameter_format(pszDest);
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
freep (arg);
|
nErrorLevel = 1;
|
||||||
return 1;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*checks to make sure user wanted/wants the override*/
|
/*checks to make sure user wanted/wants the override*/
|
||||||
|
@ -495,10 +495,16 @@ INT cmd_move (LPTSTR param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MoveStatus)
|
if (MoveStatus)
|
||||||
|
{
|
||||||
ConOutResPrintf(STRING_MOVE_ERROR1);
|
ConOutResPrintf(STRING_MOVE_ERROR1);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ConOutResPrintf(STRING_MOVE_ERROR2);
|
ConOutResPrintf(STRING_MOVE_ERROR2);
|
||||||
|
nErrorLevel = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while ((!OnlyOneFile || dwMoveStatusFlags & MOVE_SRC_CURRENT_IS_DIR ) &&
|
while ((!OnlyOneFile || dwMoveStatusFlags & MOVE_SRC_CURRENT_IS_DIR ) &&
|
||||||
!(dwMoveStatusFlags & MOVE_SOURCE_IS_DIR) &&
|
!(dwMoveStatusFlags & MOVE_SOURCE_IS_DIR) &&
|
||||||
|
@ -508,8 +514,9 @@ INT cmd_move (LPTSTR param)
|
||||||
if(hDestFile && hDestFile != INVALID_HANDLE_VALUE)
|
if(hDestFile && hDestFile != INVALID_HANDLE_VALUE)
|
||||||
FindClose(hDestFile);
|
FindClose(hDestFile);
|
||||||
|
|
||||||
freep (arg);
|
Quit:
|
||||||
return 0;
|
freep(arg);
|
||||||
|
return nErrorLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* INCLUDE_CMD_MOVE */
|
#endif /* INCLUDE_CMD_MOVE */
|
||||||
|
|
Loading…
Reference in a new issue