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

cmd.exe: Add TYPE multiple file support.

parent 085c0f4a
......@@ -1432,21 +1432,40 @@ void WCMD_title (char *command) {
* Copy a file to standard output.
*/
void WCMD_type (void) {
void WCMD_type (char *command) {
HANDLE h;
char buffer[512];
DWORD count;
int argno = 0;
char *argN = command;
BOOL writeHeaders = FALSE;
if (param1[0] == 0x00) {
WCMD_output ("Argument missing\n");
return;
}
h = CreateFile (param1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
if (param2[0] != 0x00) writeHeaders = TRUE;
/* Loop through all args */
errorlevel = 0;
while (argN) {
char *thisArg = WCMD_parameter (command, argno++, &argN);
HANDLE h;
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 ();
return;
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! */
......@@ -1454,6 +1473,8 @@ void WCMD_type (void) {
WCMD_output_asis (buffer);
}
CloseHandle (h);
}
}
}
/****************************************************************************
......
......@@ -71,7 +71,7 @@ void WCMD_setshow_time (void);
void WCMD_shift (char *command);
void WCMD_show_prompt (void);
void WCMD_title (char *);
void WCMD_type (void);
void WCMD_type (char *);
void WCMD_verify (char *command);
void WCMD_version (void);
int WCMD_volume (int mode, char *command);
......
......@@ -669,7 +669,7 @@ void WCMD_process_command (char *command)
WCMD_title(&whichcmd[count+1]);
break;
case WCMD_TYPE:
WCMD_type ();
WCMD_type (p);
break;
case WCMD_VER:
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