Commit 4ef2f8ba authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

cmd.exe: Add TYPE multiple file support.

parent 085c0f4a
...@@ -1432,28 +1432,49 @@ void WCMD_title (char *command) { ...@@ -1432,28 +1432,49 @@ void WCMD_title (char *command) {
* Copy a file to standard output. * Copy a file to standard output.
*/ */
void WCMD_type (void) { void WCMD_type (char *command) {
HANDLE h; int argno = 0;
char buffer[512]; char *argN = command;
DWORD count; BOOL writeHeaders = FALSE;
if (param1[0] == 0x00) { if (param1[0] == 0x00) {
WCMD_output ("Argument missing\n"); WCMD_output ("Argument missing\n");
return; return;
} }
h = CreateFile (param1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL); if (param2[0] != 0x00) writeHeaders = TRUE;
if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error (); /* Loop through all args */
return; errorlevel = 0;
} while (argN) {
while (ReadFile (h, buffer, sizeof(buffer), &count, NULL)) { char *thisArg = WCMD_parameter (command, argno++, &argN);
if (count == 0) break; /* ReadFile reports success on EOF! */
buffer[count] = 0; HANDLE h;
WCMD_output_asis (buffer); char buffer[512];
DWORD count;
if (!argN) break;
WINE_TRACE("type: Processing arg '%s'\n", thisArg);
h = CreateFile (thisArg, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error ();
WCMD_output ("%s :Failed\n", thisArg);
errorlevel = 1;
} else {
if (writeHeaders) {
WCMD_output("\n%s\n\n", thisArg);
}
while (ReadFile (h, buffer, sizeof(buffer), &count, NULL)) {
if (count == 0) break; /* ReadFile reports success on EOF! */
buffer[count] = 0;
WCMD_output_asis (buffer);
}
CloseHandle (h);
}
} }
CloseHandle (h);
} }
/**************************************************************************** /****************************************************************************
......
...@@ -71,7 +71,7 @@ void WCMD_setshow_time (void); ...@@ -71,7 +71,7 @@ void WCMD_setshow_time (void);
void WCMD_shift (char *command); void WCMD_shift (char *command);
void WCMD_show_prompt (void); void WCMD_show_prompt (void);
void WCMD_title (char *); void WCMD_title (char *);
void WCMD_type (void); void WCMD_type (char *);
void WCMD_verify (char *command); void WCMD_verify (char *command);
void WCMD_version (void); void WCMD_version (void);
int WCMD_volume (int mode, char *command); int WCMD_volume (int mode, char *command);
......
...@@ -669,7 +669,7 @@ void WCMD_process_command (char *command) ...@@ -669,7 +669,7 @@ void WCMD_process_command (char *command)
WCMD_title(&whichcmd[count+1]); WCMD_title(&whichcmd[count+1]);
break; break;
case WCMD_TYPE: case WCMD_TYPE:
WCMD_type (); WCMD_type (p);
break; break;
case WCMD_VER: case WCMD_VER:
WCMD_version (); WCMD_version ();
......
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