mirror of
https://github.com/reactos/reactos.git
synced 2024-10-15 05:37:44 +00:00
more.c should not close INVALID_HANDLE_VALUE
patch by Apal remove tab and quit when failing to open file (tested with Windows XP SP2) svn path=/trunk/; revision=28426
This commit is contained in:
parent
82f18756f0
commit
b4c3f2b5e3
|
@ -123,18 +123,21 @@ int main (int argc, char **argv)
|
|||
GetFullPathName(argv[1], MAX_PATH, szFullPath, NULL);
|
||||
hFile = CreateFile (szFullPath, GENERIC_READ,
|
||||
0,NULL,OPEN_ALWAYS,0,0);
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ConOutPuts(_T("The file could not be opened"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hFile = hStdIn;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if(hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
bRet = ReadFile(hFile,buff,4096,&dwRead,NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
bRet = ReadFile(hStdIn,buff,4096,&dwRead,NULL);
|
||||
}
|
||||
|
||||
for(last=i=0;i<dwRead && bRet;i++)
|
||||
{
|
||||
|
@ -161,6 +164,7 @@ int main (int argc, char **argv)
|
|||
|
||||
free (buff);
|
||||
CloseHandle (hKeyboard);
|
||||
if (hFile != hStdIn)
|
||||
CloseHandle (hFile);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue