type accepts more than one file specification
authorPaolo Pantaleo <paolopan@freemail.it>
Sat, 27 Nov 1999 19:14:59 +0000 (19:14 +0000)
committerPaolo Pantaleo <paolopan@freemail.it>
Sat, 27 Nov 1999 19:14:59 +0000 (19:14 +0000)
F3 working in command line history (for now simply the same as up arrow)

svn path=/trunk/; revision=803

rosapps/cmd/cmdinput.c
rosapps/cmd/type.c

index df69ca6..35d5b87 100644 (file)
@@ -302,7 +302,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
                                ClearCommandLine (str, maxlen, orgx, orgy);
                                current = charcount = 0;
                                break;
-
+                       case VK_F3: 
                        case VK_UP:
 #ifdef FEATURE_HISTORY
                                /* get previous command from buffer */
index 8d772dd..fc56159 100644 (file)
@@ -18,6 +18,9 @@
  *
  *    19-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
  *        Unicode and redirection ready!
+ *
+ *    19-Jan-1999 (Paolo Pantaleo <paolopan@freemail.it>)
+ *        Added multiple file support (copied from y.c)
  */
 
 #include "config.h"
 
 INT cmd_type (LPTSTR cmd, LPTSTR param)
 {
-       TCHAR  szBuffer[256];
-       HANDLE hFile;
-       DWORD  dwBytesRead;
-       DWORD  dwBytesWritten;
-       BOOL   bResult;
-       INT    args;
-       LPTSTR *arg;
+       TCHAR  buff[256];
+       HANDLE hFile, hConsoleOut, hFind;
+       DWORD  dwRead;
+       DWORD  dwWritten;
+       BOOL   bRet;
+       INT    argc,i;
+       LPTSTR *argv;
+       WIN32_FIND_DATA FindData;
+       
+       hConsoleOut=GetStdHandle (STD_OUTPUT_HANDLE);
+
+
 
        if (!_tcsncmp (param, _T("/?"), 2))
        {
@@ -54,8 +62,50 @@ INT cmd_type (LPTSTR cmd, LPTSTR param)
                return 1;
        }
 
-       arg = split (param, &args);
-
+       argv = split (param, &argc);
+       
+       for (i = 1; i < argc; i++)
+       {
+               hFind=FindFirstFile(argv[i],&FindData);
+               
+               if (hFind==INVALID_HANDLE_VALUE)
+               {
+                       ConErrPrintf("File not found - %s\n",argv[i]);
+                       continue;
+               }
+
+               do
+               {
+                       hFile = CreateFile(FindData.cFileName,
+                               GENERIC_READ,
+                               FILE_SHARE_READ,NULL,
+                               OPEN_EXISTING,
+                               FILE_ATTRIBUTE_NORMAL,NULL);
+
+                       if(hFile == INVALID_HANDLE_VALUE)
+                       {
+                               ConErrPrintf("File not found - %s\n",FindData.cFileName);
+                               continue;
+                       }
+
+                       do
+                       {
+                               bRet = ReadFile(hFile,buff,sizeof(buff),&dwRead,NULL);
+
+                               if (dwRead>0 && bRet)
+                                       WriteFile(hConsoleOut,buff,dwRead,&dwWritten,NULL);
+                       
+                       } while(dwRead>0 && bRet);
+
+                       CloseHandle(hFile);
+
+               }
+               while(FindNextFile(hFind,&FindData));
+
+               FindClose(hFile);
+       }       
+       
+/*
        if (args > 1)
        {
                error_too_many_parameters (_T("\b \b"));
@@ -86,7 +136,8 @@ INT cmd_type (LPTSTR cmd, LPTSTR param)
        while (bResult && dwBytesRead > 0);
 
        CloseHandle (hFile);
-       freep (arg);
+       */
+       freep (argv);
 
        return 0;
 }