2 * TYPE.C - type internal command.
6 * 07/08/1998 (John P. Price)
10 * Changed error messages
12 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
13 * added config.h include
15 * 07-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
16 * Added support for quoted arguments (type "test file.dat").
19 * 19-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
20 * Unicode and redirection ready!
25 #ifdef INCLUDE_CMD_TYPE
34 INT
cmd_type (LPTSTR cmd
, LPTSTR param
)
44 if (!_tcsncmp (param
, _T("/?"), 2))
46 ConOutPuts (_T("Displays the contents of text files.\n\n"
47 "TYPE [drive:][path]filename"));
53 error_req_param_missing ();
57 arg
= split (param
, &args
);
61 error_too_many_parameters (_T("\b \b"));
66 hFile
= CreateFile (arg
[0], GENERIC_READ
, FILE_SHARE_READ
,
68 FILE_ATTRIBUTE_NORMAL
| FILE_FLAG_SEQUENTIAL_SCAN
,
71 if (hFile
== INVALID_HANDLE_VALUE
)
73 error_sfile_not_found (param
);
80 bResult
= ReadFile (hFile
, szBuffer
, sizeof(szBuffer
),
83 WriteFile (GetStdHandle (STD_OUTPUT_HANDLE
), szBuffer
, dwBytesRead
,
84 &dwBytesWritten
, NULL
);
86 while (bResult
&& dwBytesRead
> 0);