mirror of
https://github.com/reactos/reactos.git
synced 2024-09-06 10:52:52 +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
|
@ -116,25 +116,28 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
buff=malloc(4096);
|
buff=malloc(4096);
|
||||||
|
|
||||||
FlushConsoleInputBuffer (hKeyboard);
|
FlushConsoleInputBuffer (hKeyboard);
|
||||||
|
|
||||||
if(argc > 1)
|
if(argc > 1)
|
||||||
{
|
{
|
||||||
GetFullPathName(argv[1], MAX_PATH, szFullPath, NULL);
|
GetFullPathName(argv[1], MAX_PATH, szFullPath, NULL);
|
||||||
hFile = CreateFile (szFullPath, GENERIC_READ,
|
hFile = CreateFile (szFullPath, GENERIC_READ,
|
||||||
0,NULL,OPEN_ALWAYS,0,0);
|
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
|
do
|
||||||
{
|
{
|
||||||
if(hFile != INVALID_HANDLE_VALUE)
|
bRet = ReadFile(hFile,buff,4096,&dwRead,NULL);
|
||||||
{
|
|
||||||
bRet = ReadFile(hFile,buff,4096,&dwRead,NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bRet = ReadFile(hStdIn,buff,4096,&dwRead,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(last=i=0;i<dwRead && bRet;i++)
|
for(last=i=0;i<dwRead && bRet;i++)
|
||||||
{
|
{
|
||||||
|
@ -161,7 +164,8 @@ int main (int argc, char **argv)
|
||||||
|
|
||||||
free (buff);
|
free (buff);
|
||||||
CloseHandle (hKeyboard);
|
CloseHandle (hKeyboard);
|
||||||
CloseHandle (hFile);
|
if (hFile != hStdIn)
|
||||||
|
CloseHandle (hFile);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue