mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 13:11:33 +00:00
Speed up batch file execution by reading a line at a time instead of a byte at a time.
svn path=/trunk/; revision=39848
This commit is contained in:
parent
642a549191
commit
eff51218fb
1 changed files with 9 additions and 8 deletions
|
@ -503,7 +503,6 @@ BOOL IsExistingDirectory (LPCTSTR pszPath)
|
||||||
BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
||||||
{
|
{
|
||||||
LPSTR lpString;
|
LPSTR lpString;
|
||||||
CHAR ch;
|
|
||||||
DWORD dwRead;
|
DWORD dwRead;
|
||||||
INT len = 0;
|
INT len = 0;
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
|
@ -511,18 +510,20 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
||||||
#else
|
#else
|
||||||
lpString = lpBuffer;
|
lpString = lpBuffer;
|
||||||
#endif
|
#endif
|
||||||
while ((--nBufferLength > 0) &&
|
|
||||||
ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead)
|
if (ReadFile(hFile, lpString, nBufferLength - 1, &dwRead, NULL))
|
||||||
{
|
|
||||||
lpString[len++] = ch;
|
|
||||||
if (ch == '\n')
|
|
||||||
{
|
{
|
||||||
/* break at new line*/
|
/* break at new line*/
|
||||||
break;
|
CHAR *end = memchr(lpString, '\n', dwRead);
|
||||||
|
len = dwRead;
|
||||||
|
if (end)
|
||||||
|
{
|
||||||
|
len = (end - lpString) + 1;
|
||||||
|
SetFilePointer(hFile, len - dwRead, NULL, FILE_CURRENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dwRead && !len)
|
if (!len)
|
||||||
{
|
{
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
cmd_free(lpString);
|
cmd_free(lpString);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue