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!
22 * 19-Jan-1999 (Paolo Pantaleo <paolopan@freemail.it>)
23 * Added multiple file support (copied from y.c)
28 #ifdef INCLUDE_CMD_TYPE
37 INT cmd_type (LPTSTR cmd, LPTSTR param)
40 HANDLE hFile, hConsoleOut;
48 hConsoleOut=GetStdHandle (STD_OUTPUT_HANDLE);
50 if (!_tcsncmp (param, _T("/?"), 2))
52 ConOutPuts (_T("Displays the contents of text files.\n\n"
53 "TYPE [drive:][path]filename"));
59 error_req_param_missing ();
63 argv = split (param, &argc, TRUE);
65 for (i = 0; i < argc; i++)
67 if (_T('/') == argv[i][0])
69 ConErrPrintf("Invalid option \"%s\"\n", argv[i] + 1);
72 hFile = CreateFile(argv[i],
76 FILE_ATTRIBUTE_NORMAL,NULL);
78 if(hFile == INVALID_HANDLE_VALUE)
80 FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
81 FORMAT_MESSAGE_IGNORE_INSERTS |
82 FORMAT_MESSAGE_FROM_SYSTEM,
85 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
89 ConErrPrintf ("%s - %s", argv[i], errmsg);
96 bRet = ReadFile(hFile,buff,sizeof(buff),&dwRead,NULL);
99 WriteFile(hConsoleOut,buff,dwRead,&dwWritten,NULL);
101 } while(dwRead>0 && bRet);