mirror of
https://github.com/wine-mirror/wine
synced 2024-07-03 08:19:41 +00:00
cmd: Use kernel32's error codes instead of literals.
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
parent
2ec70835fc
commit
844d6b553a
|
@ -654,7 +654,7 @@ void WCMD_call (WCHAR *command) {
|
||||||
if (*command != ':') {
|
if (*command != ':') {
|
||||||
WCMD_run_program(command, TRUE);
|
WCMD_run_program(command, TRUE);
|
||||||
/* If the thing we try to run does not exist, call returns 1 */
|
/* If the thing we try to run does not exist, call returns 1 */
|
||||||
if (errorlevel) errorlevel=1;
|
if (errorlevel) errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
WCHAR gotoLabel[MAX_PATH];
|
WCHAR gotoLabel[MAX_PATH];
|
||||||
|
|
|
@ -303,7 +303,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
BOOL opt_s = FALSE;
|
BOOL opt_s = FALSE;
|
||||||
|
|
||||||
have_console = GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &oldmode);
|
have_console = GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &oldmode);
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
|
|
||||||
my_command = xstrdupW(WCMD_skip_leading_spaces((WCHAR*)args));
|
my_command = xstrdupW(WCMD_skip_leading_spaces((WCHAR*)args));
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
if (!WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), answer, 1, &count))
|
if (!WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), answer, 1, &count))
|
||||||
{
|
{
|
||||||
free(my_command);
|
free(my_command);
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,12 +641,12 @@ void WCMD_copy(WCHAR * args) {
|
||||||
COPY_FILES *prevcopy = NULL;
|
COPY_FILES *prevcopy = NULL;
|
||||||
|
|
||||||
/* Assume we were successful! */
|
/* Assume we were successful! */
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
|
|
||||||
/* If no args supplied at all, report an error */
|
/* If no args supplied at all, report an error */
|
||||||
if (param1[0] == 0x00) {
|
if (param1[0] == 0x00) {
|
||||||
WCMD_output_stderr (WCMD_LoadMessage(WCMD_NOARG));
|
WCMD_output_stderr (WCMD_LoadMessage(WCMD_NOARG));
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
if (*thisparam=='+') {
|
if (*thisparam=='+') {
|
||||||
if (lastcopyentry == NULL) {
|
if (lastcopyentry == NULL) {
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
goto exitreturn;
|
goto exitreturn;
|
||||||
} else {
|
} else {
|
||||||
concatnextfilename = TRUE;
|
concatnextfilename = TRUE;
|
||||||
|
@ -781,7 +781,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
} else {
|
} else {
|
||||||
/* We have processed sources and destinations and still found more to do - invalid */
|
/* We have processed sources and destinations and still found more to do - invalid */
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
goto exitreturn;
|
goto exitreturn;
|
||||||
}
|
}
|
||||||
concatnextfilename = FALSE;
|
concatnextfilename = FALSE;
|
||||||
|
@ -798,7 +798,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
/* Ensure we have at least one source file */
|
/* Ensure we have at least one source file */
|
||||||
if (!sourcelist) {
|
if (!sourcelist) {
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
goto exitreturn;
|
goto exitreturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1046,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
}
|
}
|
||||||
if (!status) {
|
if (!status) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
} else {
|
} else {
|
||||||
WINE_TRACE("Copied successfully\n");
|
WINE_TRACE("Copied successfully\n");
|
||||||
if (anyconcats) writtenoneconcat = TRUE;
|
if (anyconcats) writtenoneconcat = TRUE;
|
||||||
|
@ -1058,7 +1058,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
if (!destination->binarycopy && !anyconcats && !thiscopy->binarycopy) {
|
if (!destination->binarycopy && !anyconcats && !thiscopy->binarycopy) {
|
||||||
if (!WCMD_AppendEOF(outname)) {
|
if (!WCMD_AppendEOF(outname)) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1070,7 +1070,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
/* Error if the first file was not found */
|
/* Error if the first file was not found */
|
||||||
if (!anyconcats || !writtenoneconcat) {
|
if (!anyconcats || !writtenoneconcat) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1082,7 +1082,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
if (!errorlevel && !destination->binarycopy && anyconcats && writtenoneconcat) {
|
if (!errorlevel && !destination->binarycopy && anyconcats && writtenoneconcat) {
|
||||||
if (!WCMD_AppendEOF(destination->name)) {
|
if (!WCMD_AppendEOF(destination->name)) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,7 +1165,7 @@ void WCMD_create_dir (WCHAR *args) {
|
||||||
if (!argN) break;
|
if (!argN) break;
|
||||||
if (!create_full_path(thisArg)) {
|
if (!create_full_path(thisArg)) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1444,7 +1444,7 @@ BOOL WCMD_delete (WCHAR *args) {
|
||||||
BOOL argsProcessed = FALSE;
|
BOOL argsProcessed = FALSE;
|
||||||
BOOL foundAny = FALSE;
|
BOOL foundAny = FALSE;
|
||||||
|
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
|
|
||||||
for (argno=0; ; argno++) {
|
for (argno=0; ; argno++) {
|
||||||
BOOL found;
|
BOOL found;
|
||||||
|
@ -2053,7 +2053,7 @@ void WCMD_pushd (const WCHAR *args)
|
||||||
/* Change directory using CD code with /D parameter */
|
/* Change directory using CD code with /D parameter */
|
||||||
lstrcpyW(quals, L"/D");
|
lstrcpyW(quals, L"/D");
|
||||||
GetCurrentDirectoryW (1024, thisdir);
|
GetCurrentDirectoryW (1024, thisdir);
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
WCMD_setshow_default(args);
|
WCMD_setshow_default(args);
|
||||||
if (errorlevel) {
|
if (errorlevel) {
|
||||||
LocalFree(curdir);
|
LocalFree(curdir);
|
||||||
|
@ -2253,7 +2253,7 @@ void WCMD_move (void)
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
} while (FindNextFileW(hff, &fd) != 0);
|
} while (FindNextFileW(hff, &fd) != 0);
|
||||||
|
|
||||||
|
@ -2368,12 +2368,12 @@ void WCMD_rename (void)
|
||||||
WCHAR fname[MAX_PATH];
|
WCHAR fname[MAX_PATH];
|
||||||
WCHAR ext[MAX_PATH];
|
WCHAR ext[MAX_PATH];
|
||||||
|
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
|
|
||||||
/* Must be at least two args */
|
/* Must be at least two args */
|
||||||
if (param1[0] == 0x00 || param2[0] == 0x00) {
|
if (param1[0] == 0x00 || param2[0] == 0x00) {
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG));
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG));
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2381,7 +2381,7 @@ void WCMD_rename (void)
|
||||||
if ((wcschr(param2,':') != NULL) || (wcschr(param2,'\\') != NULL)) {
|
if ((wcschr(param2,':') != NULL) || (wcschr(param2,'\\') != NULL)) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2444,7 +2444,7 @@ void WCMD_rename (void)
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
} while (FindNextFileW(hff, &fd) != 0);
|
} while (FindNextFileW(hff, &fd) != 0);
|
||||||
|
|
||||||
|
@ -2683,7 +2683,7 @@ void WCMD_setshow_default (const WCHAR *args) {
|
||||||
|
|
||||||
status = SetCurrentDirectoryW(string);
|
status = SetCurrentDirectoryW(string);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3432,7 +3432,7 @@ void WCMD_setshow_env (WCHAR *s) {
|
||||||
env = GetEnvironmentStringsW();
|
env = GetEnvironmentStringsW();
|
||||||
if (WCMD_setshow_sortenv( env, s ) == 0) {
|
if (WCMD_setshow_sortenv( env, s ) == 0) {
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_MISSINGENV), s);
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_MISSINGENV), s);
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3444,9 +3444,9 @@ void WCMD_setshow_env (WCHAR *s) {
|
||||||
status = SetEnvironmentVariableW(s, p);
|
status = SetEnvironmentVariableW(s, p);
|
||||||
gle = GetLastError();
|
gle = GetLastError();
|
||||||
if ((!status) & (gle == ERROR_ENVVAR_NOT_FOUND)) {
|
if ((!status) & (gle == ERROR_ENVVAR_NOT_FOUND)) {
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
} else if (!status) WCMD_print_error();
|
} else if (!status) WCMD_print_error();
|
||||||
else if (!interactive) errorlevel = 0;
|
else if (!interactive) errorlevel = NO_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3675,7 +3675,7 @@ void WCMD_start(WCHAR *args)
|
||||||
DWORD exit_code;
|
DWORD exit_code;
|
||||||
WaitForSingleObject( pi.hProcess, INFINITE );
|
WaitForSingleObject( pi.hProcess, INFINITE );
|
||||||
GetExitCodeProcess( pi.hProcess, &exit_code );
|
GetExitCodeProcess( pi.hProcess, &exit_code );
|
||||||
errorlevel = (exit_code == STILL_ACTIVE) ? 0 : exit_code;
|
errorlevel = (exit_code == STILL_ACTIVE) ? NO_ERROR : exit_code;
|
||||||
CloseHandle(pi.hProcess);
|
CloseHandle(pi.hProcess);
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
}
|
}
|
||||||
|
@ -3683,7 +3683,7 @@ void WCMD_start(WCHAR *args)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_FILE_NOT_FOUND);
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 9009;
|
errorlevel = RETURN_CODE_CANT_LAUNCH;
|
||||||
}
|
}
|
||||||
free(cmdline);
|
free(cmdline);
|
||||||
}
|
}
|
||||||
|
@ -3717,7 +3717,7 @@ void WCMD_type (WCHAR *args) {
|
||||||
if (param2[0] != 0x00) writeHeaders = TRUE;
|
if (param2[0] != 0x00) writeHeaders = TRUE;
|
||||||
|
|
||||||
/* Loop through all args */
|
/* Loop through all args */
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
while (argN) {
|
while (argN) {
|
||||||
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, FALSE, FALSE);
|
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, FALSE, FALSE);
|
||||||
|
|
||||||
|
@ -3733,7 +3733,7 @@ void WCMD_type (WCHAR *args) {
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), thisArg);
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), thisArg);
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
} else {
|
} else {
|
||||||
if (writeHeaders) {
|
if (writeHeaders) {
|
||||||
WCMD_output_stderr(L"\n%1\n\n\n", thisArg);
|
WCMD_output_stderr(L"\n%1\n\n\n", thisArg);
|
||||||
|
@ -3764,7 +3764,7 @@ void WCMD_more (WCHAR *args) {
|
||||||
DWORD count;
|
DWORD count;
|
||||||
|
|
||||||
/* Prefix the NLS more with '-- ', then load the text */
|
/* Prefix the NLS more with '-- ', then load the text */
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
lstrcpyW(moreStr, L"-- ");
|
lstrcpyW(moreStr, L"-- ");
|
||||||
LoadStringW(hinst, WCMD_MORESTR, &moreStr[3], ARRAY_SIZE(moreStr)-3);
|
LoadStringW(hinst, WCMD_MORESTR, &moreStr[3], ARRAY_SIZE(moreStr)-3);
|
||||||
|
|
||||||
|
@ -3828,7 +3828,7 @@ void WCMD_more (WCHAR *args) {
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), thisArg);
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), thisArg);
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
} else {
|
} else {
|
||||||
ULONG64 curPos = 0;
|
ULONG64 curPos = 0;
|
||||||
ULONG64 fileLen = 0;
|
ULONG64 fileLen = 0;
|
||||||
|
@ -3996,7 +3996,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
|
||||||
HKEY readKey;
|
HKEY readKey;
|
||||||
|
|
||||||
/* See if parameter includes '=' */
|
/* See if parameter includes '=' */
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
newValue = wcschr(args, '=');
|
newValue = wcschr(args, '=');
|
||||||
if (newValue) accessOptions |= KEY_WRITE;
|
if (newValue) accessOptions |= KEY_WRITE;
|
||||||
|
|
||||||
|
@ -4084,7 +4084,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
|
||||||
LoadStringW(hinst, WCMD_NOFTYPE, msgbuffer, ARRAY_SIZE(msgbuffer));
|
LoadStringW(hinst, WCMD_NOFTYPE, msgbuffer, ARRAY_SIZE(msgbuffer));
|
||||||
}
|
}
|
||||||
WCMD_output_stderr(msgbuffer, keyValue);
|
WCMD_output_stderr(msgbuffer, keyValue);
|
||||||
errorlevel = 2;
|
errorlevel = ERROR_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not a query - it's a set or clear of a value */
|
/* Not a query - it's a set or clear of a value */
|
||||||
|
@ -4109,7 +4109,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
|
||||||
|
|
||||||
} else if (assoc && rc != ERROR_FILE_NOT_FOUND) {
|
} else if (assoc && rc != ERROR_FILE_NOT_FOUND) {
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
errorlevel = 2;
|
errorlevel = ERROR_FILE_NOT_FOUND;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
WCHAR msgbuffer[MAXSTRING];
|
WCHAR msgbuffer[MAXSTRING];
|
||||||
|
@ -4121,7 +4121,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
|
||||||
LoadStringW(hinst, WCMD_NOFTYPE, msgbuffer, ARRAY_SIZE(msgbuffer));
|
LoadStringW(hinst, WCMD_NOFTYPE, msgbuffer, ARRAY_SIZE(msgbuffer));
|
||||||
}
|
}
|
||||||
WCMD_output_stderr(msgbuffer, args);
|
WCMD_output_stderr(msgbuffer, args);
|
||||||
errorlevel = 2;
|
errorlevel = ERROR_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It really is a set value = contents */
|
/* It really is a set value = contents */
|
||||||
|
@ -4137,7 +4137,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
|
||||||
|
|
||||||
if (rc != ERROR_SUCCESS) {
|
if (rc != ERROR_SUCCESS) {
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
errorlevel = 2;
|
errorlevel = ERROR_FILE_NOT_FOUND;
|
||||||
} else {
|
} else {
|
||||||
WCMD_output_asis(args);
|
WCMD_output_asis(args);
|
||||||
WCMD_output_asis(L"=");
|
WCMD_output_asis(L"=");
|
||||||
|
@ -4188,7 +4188,7 @@ void WCMD_color (void) {
|
||||||
|
|
||||||
/* Fail if fg == bg color */
|
/* Fail if fg == bg color */
|
||||||
if (((color & 0xF0) >> 4) == (color & 0x0F)) {
|
if (((color & 0xF0) >> 4) == (color & 0x0F)) {
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -494,7 +494,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
||||||
if ((file_total + dir_total == 0) && (level == 0)) {
|
if ((file_total + dir_total == 0) && (level == 0)) {
|
||||||
SetLastError (ERROR_FILE_NOT_FOUND);
|
SetLastError (ERROR_FILE_NOT_FOUND);
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parms;
|
return parms;
|
||||||
|
@ -513,7 +513,7 @@ static void WCMD_dir_trailer(const WCHAR *path) {
|
||||||
WINE_TRACE("Writing trailer for '%s' gave %d(%ld)\n", wine_dbgstr_w(path),
|
WINE_TRACE("Writing trailer for '%s' gave %d(%ld)\n", wine_dbgstr_w(path),
|
||||||
status, GetLastError());
|
status, GetLastError());
|
||||||
|
|
||||||
if (errorlevel==0 && !bare) {
|
if (errorlevel == NO_ERROR && !bare) {
|
||||||
if (recurse) {
|
if (recurse) {
|
||||||
WCMD_output (L"\n Total files listed:\n%1!8d! files%2!25s! bytes\n", file_total, WCMD_filesize64 (byte_total));
|
WCMD_output (L"\n Total files listed:\n%1!8d! files%2!25s! bytes\n", file_total, WCMD_filesize64 (byte_total));
|
||||||
WCMD_output (L"%1!8d! directories %2!18s! bytes free\n\n", dir_total, WCMD_filesize64 (freebytes.QuadPart));
|
WCMD_output (L"%1!8d! directories %2!18s! bytes free\n\n", dir_total, WCMD_filesize64 (freebytes.QuadPart));
|
||||||
|
@ -650,7 +650,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
WCHAR fname[MAX_PATH];
|
WCHAR fname[MAX_PATH];
|
||||||
WCHAR ext[MAX_PATH];
|
WCHAR ext[MAX_PATH];
|
||||||
|
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
|
|
||||||
/* Prefill quals with (uppercased) DIRCMD env var */
|
/* Prefill quals with (uppercased) DIRCMD env var */
|
||||||
if (GetEnvironmentVariableW(L"DIRCMD", string, ARRAY_SIZE(string))) {
|
if (GetEnvironmentVariableW(L"DIRCMD", string, ARRAY_SIZE(string))) {
|
||||||
|
@ -736,7 +736,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
} else {
|
} else {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -756,7 +756,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
default:
|
default:
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
|
@ -787,7 +787,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
default:
|
default:
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,7 +806,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
default:
|
default:
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p = p + 1;
|
p = p + 1;
|
||||||
|
@ -945,7 +945,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
status = WCMD_volume (0, drive);
|
status = WCMD_volume (0, drive);
|
||||||
trailerReqd = TRUE;
|
trailerReqd = TRUE;
|
||||||
if (!status) {
|
if (!status) {
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -954,7 +954,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear any errors from previous invocations, and process it */
|
/* Clear any errors from previous invocations, and process it */
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
prevEntry = thisEntry;
|
prevEntry = thisEntry;
|
||||||
thisEntry = WCMD_list_directory (thisEntry, 0);
|
thisEntry = WCMD_list_directory (thisEntry, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,14 @@ void WCMD_add_dirstowalk(struct _DIRECTORY_STACK *dirsToWalk);
|
||||||
struct _DIRECTORY_STACK *WCMD_dir_stack_create(const WCHAR *dir, const WCHAR *file);
|
struct _DIRECTORY_STACK *WCMD_dir_stack_create(const WCHAR *dir, const WCHAR *file);
|
||||||
struct _DIRECTORY_STACK *WCMD_dir_stack_free(struct _DIRECTORY_STACK *dir);
|
struct _DIRECTORY_STACK *WCMD_dir_stack_free(struct _DIRECTORY_STACK *dir);
|
||||||
|
|
||||||
|
/* The return code:
|
||||||
|
* - some of them are directly mapped to kernel32's errors
|
||||||
|
* - some others are cmd.exe specific
|
||||||
|
*/
|
||||||
|
typedef int RETURN_CODE;
|
||||||
|
#define RETURN_CODE_SYNTAX_ERROR 255
|
||||||
|
#define RETURN_CODE_CANT_LAUNCH 9009
|
||||||
|
|
||||||
void WCMD_assoc (const WCHAR *, BOOL);
|
void WCMD_assoc (const WCHAR *, BOOL);
|
||||||
void WCMD_batch (WCHAR *, WCHAR *, BOOL, WCHAR *, HANDLE);
|
void WCMD_batch (WCHAR *, WCHAR *, BOOL, WCHAR *, HANDLE);
|
||||||
void WCMD_call (WCHAR *command);
|
void WCMD_call (WCHAR *command);
|
||||||
|
|
|
@ -1381,7 +1381,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
if (!firstParam) return;
|
if (!firstParam) return;
|
||||||
|
|
||||||
if (!firstParam[0]) {
|
if (!firstParam[0]) {
|
||||||
errorlevel = 0;
|
errorlevel = NO_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1580,7 +1580,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
if (!interactive || (console && !HIWORD(console)))
|
if (!interactive || (console && !HIWORD(console)))
|
||||||
WaitForSingleObject (pe.hProcess, INFINITE);
|
WaitForSingleObject (pe.hProcess, INFINITE);
|
||||||
GetExitCodeProcess (pe.hProcess, &exit_code);
|
GetExitCodeProcess (pe.hProcess, &exit_code);
|
||||||
errorlevel = (exit_code == STILL_ACTIVE) ? 0 : exit_code;
|
errorlevel = (exit_code == STILL_ACTIVE) ? NO_ERROR : exit_code;
|
||||||
|
|
||||||
CloseHandle(pe.hProcess);
|
CloseHandle(pe.hProcess);
|
||||||
CloseHandle(pe.hThread);
|
CloseHandle(pe.hThread);
|
||||||
|
@ -1606,7 +1606,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
|
|
||||||
/* If a command fails to launch, it sets errorlevel 9009 - which
|
/* If a command fails to launch, it sets errorlevel 9009 - which
|
||||||
does not seem to have any associated constant definition */
|
does not seem to have any associated constant definition */
|
||||||
errorlevel = 9009;
|
errorlevel = RETURN_CODE_CANT_LAUNCH;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3096,7 +3096,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_NODE **output, HANDLE
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
WINE_TRACE("Brackets do not match, error out without executing.\n");
|
WINE_TRACE("Brackets do not match, error out without executing.\n");
|
||||||
errorlevel = 255;
|
errorlevel = RETURN_CODE_SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return extraSpace;
|
return extraSpace;
|
||||||
|
@ -3385,7 +3385,7 @@ static CMD_NODE *for_control_execute_fileset(CMD_FOR_CONTROL *for_ctrl, CMD_NODE
|
||||||
{
|
{
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), args);
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), args);
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return NULL; /* FOR loop aborts at first failure here */
|
return NULL; /* FOR loop aborts at first failure here */
|
||||||
}
|
}
|
||||||
body = for_control_execute_from_FILE(for_ctrl, input, cmdList);
|
body = for_control_execute_from_FILE(for_ctrl, input, cmdList);
|
||||||
|
@ -3405,7 +3405,7 @@ static CMD_NODE *for_control_execute_fileset(CMD_FOR_CONTROL *for_ctrl, CMD_NODE
|
||||||
{
|
{
|
||||||
WCMD_print_error();
|
WCMD_print_error();
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), element);
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), element);
|
||||||
errorlevel = 1;
|
errorlevel = ERROR_INVALID_FUNCTION;
|
||||||
return NULL; /* FOR loop aborts at first failure here */
|
return NULL; /* FOR loop aborts at first failure here */
|
||||||
}
|
}
|
||||||
body = for_control_execute_from_FILE(for_ctrl, input, cmdList);
|
body = for_control_execute_from_FILE(for_ctrl, input, cmdList);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user