cmd: Set success/failure return code for MOVE command.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
Eric Pouech 2024-06-27 17:46:11 +02:00 committed by Alexandre Julliard
parent ca3b24733a
commit 90d278f932
4 changed files with 18 additions and 21 deletions

View file

@ -1928,11 +1928,10 @@ void WCMD_popd (void) {
* Move a file, directory tree or wildcarded set of files.
*/
void WCMD_move (void)
RETURN_CODE WCMD_move(void)
{
BOOL status;
WIN32_FIND_DATAW fd;
HANDLE hff;
HANDLE hff;
WCHAR input[MAX_PATH];
WCHAR output[MAX_PATH];
WCHAR drive[10];
@ -1942,7 +1941,7 @@ void WCMD_move (void)
if (param1[0] == 0x00) {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG));
return;
return errorlevel = ERROR_INVALID_FUNCTION;
}
/* If no destination supplied, assume current directory */
@ -1953,7 +1952,8 @@ void WCMD_move (void)
/* If 2nd parm is directory, then use original filename */
/* Convert partial path to full path */
if (!WCMD_get_fullpath(param1, ARRAY_SIZE(input), input, NULL) ||
!WCMD_get_fullpath(param2, ARRAY_SIZE(output), output, NULL)) return;
!WCMD_get_fullpath(param2, ARRAY_SIZE(output), output, NULL))
return errorlevel = ERROR_INVALID_FUNCTION;
WINE_TRACE("Move from '%s'('%s') to '%s'\n", wine_dbgstr_w(input),
wine_dbgstr_w(param1), wine_dbgstr_w(output));
@ -1962,8 +1962,9 @@ void WCMD_move (void)
hff = FindFirstFileW(input, &fd);
if (hff == INVALID_HANDLE_VALUE)
return;
return errorlevel = ERROR_INVALID_FUNCTION;
errorlevel = NO_ERROR;
do {
WCHAR dest[MAX_PATH];
WCHAR src[MAX_PATH];
@ -2036,19 +2037,15 @@ void WCMD_move (void)
flags |= MOVEFILE_REPLACE_EXISTING;
}
if (ok) {
status = MoveFileExW(src, dest, flags);
} else {
status = TRUE;
}
if (!status) {
WCMD_print_error ();
if (!ok || !MoveFileExW(src, dest, flags))
{
if (!ok) WCMD_print_error();
errorlevel = ERROR_INVALID_FUNCTION;
}
} while (FindNextFileW(hff, &fd) != 0);
FindClose(hff);
return errorlevel;
}
/****************************************************************************

View file

@ -480,11 +480,11 @@ SUCCESS 0
@todo_wine@FAILURE 1
@todo_wine@FAILURE 1
--- success/failure for MOVE command
@todo_wine@FAILURE 1
@todo_wine@SUCCESS 0
@todo_wine@FAILURE 1
@todo_wine@FAILURE 1
@todo_wine@FAILURE 1
FAILURE 1
SUCCESS 0
FAILURE 1
FAILURE 1
FAILURE 1
--- success/failure for RENAME command
@todo_wine@FAILURE 1
@todo_wine@FAILURE 1

View file

@ -179,7 +179,7 @@ void WCMD_give_help (const WCHAR *args);
RETURN_CODE WCMD_goto(void);
void WCMD_leave_paged_mode(void);
void WCMD_more (WCHAR *);
void WCMD_move (void);
RETURN_CODE WCMD_move (void);
WCHAR* WINAPIV WCMD_format_string (const WCHAR *format, ...);
void WINAPIV WCMD_output (const WCHAR *format, ...);
void WINAPIV WCMD_output_stderr (const WCHAR *format, ...);

View file

@ -1852,7 +1852,7 @@ static RETURN_CODE execute_single_command(const WCHAR *command)
WCMD_create_dir (parms_start);
break;
case WCMD_MOVE:
WCMD_move ();
return_code = WCMD_move();
break;
case WCMD_PATH:
WCMD_setshow_path (parms_start);