Author: jmorlan
Date: Mon Feb 16 15:50:54 2009
New Revision: 39628
URL:
http://svn.reactos.org/svn/reactos?rev=39628&view=rev
Log:
- Improve performance of TYPE command by reading more than 1 byte at a time. (Bug 4057)
- Also allow it to be interrupted by ^C.
Modified:
trunk/reactos/base/shell/cmd/type.c
Modified: trunk/reactos/base/shell/cmd/type.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/type.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/type.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/type.c [iso-8859-1] Mon Feb 16 15:50:54 2009
@@ -35,7 +35,7 @@
{
TCHAR buff[256];
HANDLE hFile, hConsoleOut;
- BOOL bRet;
+ DWORD dwRet;
INT argc,i;
LPTSTR *argv;
LPTSTR errmsg;
@@ -99,28 +99,34 @@
continue;
}
- do
+ if (bPaging)
{
- bRet = FileGetString (hFile, buff, sizeof(buff) / sizeof(TCHAR));
- if(bPaging)
+ while (FileGetString (hFile, buff, sizeof(buff) / sizeof(TCHAR)))
{
- if(bRet)
+ if (ConOutPrintfPaging(bFirstTime, _T("%s"), buff) == 1)
{
- if (ConOutPrintfPaging(bFirstTime, _T("%s"), buff) == 1)
- {
- bCtrlBreak = FALSE;
- return 0;
- }
+ bCtrlBreak = FALSE;
+ CloseHandle(hFile);
+ freep(argv);
+ return 0;
+ }
+ bFirstTime = FALSE;
+ }
+ }
+ else
+ {
+ while (ReadFile(hFile, buff, sizeof(buff), &dwRet, NULL) && dwRet > 0)
+ {
+ WriteFile(hConsoleOut, buff, dwRet, &dwRet, NULL);
+ if (bCtrlBreak)
+ {
+ bCtrlBreak = FALSE;
+ CloseHandle(hFile);
+ freep(argv);
+ return 0;
}
}
- else
- {
- if(bRet)
- ConOutPrintf(_T("%s"), buff);
- }
- bFirstTime = FALSE;
-
- } while(bRet);
+ }
CloseHandle(hFile);
}