cmd.exe: Add TYPE multiple file support.

This commit is contained in:
Jason Edmeades 2007-03-13 00:09:33 +00:00 committed by Alexandre Julliard
parent 085c0f4a3a
commit 4ef2f8ba1a
3 changed files with 38 additions and 17 deletions

View File

@ -1432,28 +1432,49 @@ 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,
FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error ();
return;
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 ();
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);
}
}
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);
}
/****************************************************************************

View File

@ -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);

View File

@ -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 ();