- Improve performance of TYPE command by reading more than 1 byte at a time. (Bug 4057)

- Also allow it to be interrupted by ^C.

svn path=/trunk/; revision=39628
This commit is contained in:
Jeffrey Morlan 2009-02-16 21:50:54 +00:00
parent 1d38fb2424
commit dc8e4248dd

View file

@ -35,7 +35,7 @@ INT cmd_type (LPTSTR param)
{
TCHAR buff[256];
HANDLE hFile, hConsoleOut;
BOOL bRet;
DWORD dwRet;
INT argc,i;
LPTSTR *argv;
LPTSTR errmsg;
@ -99,28 +99,34 @@ INT cmd_type (LPTSTR param)
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);
}