From: Johannes Anderwald Date: Sun, 19 Aug 2007 20:16:10 +0000 (+0000) Subject: more.c should not close INVALID_HANDLE_VALUE X-Git-Tag: ReactOS-0.3.3~21^2~6 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=b4c3f2b5e3f371ffa1924e68463918aea9a03573 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 --- diff --git a/reactos/base/applications/cmdutils/more/more.c b/reactos/base/applications/cmdutils/more/more.c index 7ce956d28b3..ae6bf36cac6 100644 --- a/reactos/base/applications/cmdutils/more/more.c +++ b/reactos/base/applications/cmdutils/more/more.c @@ -116,25 +116,28 @@ int main (int argc, char **argv) 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