Author: janderwald Date: Mon Aug 20 00:16:10 2007 New Revision: 28426
URL: http://svn.reactos.org/svn/reactos?rev=28426&view=rev Log: 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)
Modified: trunk/reactos/base/applications/cmdutils/more/more.c
Modified: trunk/reactos/base/applications/cmdutils/more/more.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils/... ============================================================================== --- trunk/reactos/base/applications/cmdutils/more/more.c (original) +++ trunk/reactos/base/applications/cmdutils/more/more.c Mon Aug 20 00:16:10 2007 @@ -116,25 +116,28 @@
buff=malloc(4096);
- FlushConsoleInputBuffer (hKeyboard); + FlushConsoleInputBuffer (hKeyboard);
if(argc > 1) { 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); - } + bRet = ReadFile(hFile,buff,4096,&dwRead,NULL);
for(last=i=0;i<dwRead && bRet;i++) { @@ -161,7 +164,8 @@
free (buff); CloseHandle (hKeyboard); - CloseHandle (hFile); + if (hFile != hStdIn) + CloseHandle (hFile);
return 0; }