Commit bf626f96 authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

cmd.exe: Add errorlevel support for DIR command.

parent d2244794
...@@ -82,6 +82,8 @@ void WCMD_directory (void) { ...@@ -82,6 +82,8 @@ void WCMD_directory (void) {
char *p; char *p;
char string[MAXSTRING]; char string[MAXSTRING];
errorlevel = 0;
/* Prefill Quals with (uppercased) DIRCMD env var */ /* Prefill Quals with (uppercased) DIRCMD env var */
if (GetEnvironmentVariable ("DIRCMD", string, sizeof(string))) { if (GetEnvironmentVariable ("DIRCMD", string, sizeof(string))) {
p = string; p = string;
...@@ -167,6 +169,7 @@ void WCMD_directory (void) { ...@@ -167,6 +169,7 @@ void WCMD_directory (void) {
} else { } else {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
WCMD_print_error(); WCMD_print_error();
errorlevel = 1;
return; return;
} }
break; break;
...@@ -186,6 +189,7 @@ void WCMD_directory (void) { ...@@ -186,6 +189,7 @@ void WCMD_directory (void) {
default: default:
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
WCMD_print_error(); WCMD_print_error();
errorlevel = 1;
return; return;
} }
p++; p++;
...@@ -216,6 +220,7 @@ void WCMD_directory (void) { ...@@ -216,6 +220,7 @@ void WCMD_directory (void) {
default: default:
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
WCMD_print_error(); WCMD_print_error();
errorlevel = 1;
return; return;
} }
...@@ -234,6 +239,7 @@ void WCMD_directory (void) { ...@@ -234,6 +239,7 @@ void WCMD_directory (void) {
default: default:
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
WCMD_print_error(); WCMD_print_error();
errorlevel = 1;
return; return;
} }
p = p + 1; p = p + 1;
...@@ -260,6 +266,7 @@ void WCMD_directory (void) { ...@@ -260,6 +266,7 @@ void WCMD_directory (void) {
if (!status) { if (!status) {
WCMD_print_error(); WCMD_print_error();
if (paged_mode) WCMD_leave_paged_mode(); if (paged_mode) WCMD_leave_paged_mode();
errorlevel = 1;
return; return;
} }
lstrcpyn (drive, path, 3); lstrcpyn (drive, path, 3);
...@@ -268,6 +275,7 @@ void WCMD_directory (void) { ...@@ -268,6 +275,7 @@ void WCMD_directory (void) {
status = WCMD_volume (0, drive); status = WCMD_volume (0, drive);
if (!status) { if (!status) {
if (paged_mode) WCMD_leave_paged_mode(); if (paged_mode) WCMD_leave_paged_mode();
errorlevel = 1;
return; return;
} }
} }
...@@ -352,6 +360,7 @@ void WCMD_list_directory (char *search_path, int level) { ...@@ -352,6 +360,7 @@ void WCMD_list_directory (char *search_path, int level) {
SetLastError (ERROR_FILE_NOT_FOUND); SetLastError (ERROR_FILE_NOT_FOUND);
WCMD_print_error (); WCMD_print_error ();
HeapFree(GetProcessHeap(),0,fd); HeapFree(GetProcessHeap(),0,fd);
errorlevel = 1;
return; return;
} }
do { do {
...@@ -371,6 +380,7 @@ void WCMD_list_directory (char *search_path, int level) { ...@@ -371,6 +380,7 @@ void WCMD_list_directory (char *search_path, int level) {
if (fd == NULL) { if (fd == NULL) {
FindClose (hff); FindClose (hff);
WCMD_output ("Memory Allocation Error"); WCMD_output ("Memory Allocation Error");
errorlevel = 1;
return; return;
} }
} while (FindNextFile(hff, (fd+entry_count)) != 0); } while (FindNextFile(hff, (fd+entry_count)) != 0);
...@@ -381,6 +391,7 @@ void WCMD_list_directory (char *search_path, int level) { ...@@ -381,6 +391,7 @@ void WCMD_list_directory (char *search_path, int level) {
SetLastError (ERROR_FILE_NOT_FOUND); SetLastError (ERROR_FILE_NOT_FOUND);
WCMD_print_error (); WCMD_print_error ();
HeapFree(GetProcessHeap(),0,fd); HeapFree(GetProcessHeap(),0,fd);
errorlevel = 1;
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment