From 12e906948005b9b2f267fe76263457a628cd17c8 Mon Sep 17 00:00:00 2001 From: jean Date: Thu, 25 Jan 2001 18:55:33 +0000 Subject: [PATCH] correct some arguments for CreateFile svn path=/trunk/; revision=1569 --- reactos/lib/crtdll/io/open.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/reactos/lib/crtdll/io/open.c b/reactos/lib/crtdll/io/open.c index fdbc2efe934..4cc7e33eb6e 100644 --- a/reactos/lib/crtdll/io/open.c +++ b/reactos/lib/crtdll/io/open.c @@ -13,6 +13,7 @@ // possibly store extra information at the handle #include +#include #include #include #include @@ -50,15 +51,17 @@ int _open(const char *_path, int _oflag,...) { HANDLE hFile; DWORD dwDesiredAccess = 0; - DWORD dwShareMode = 0; + DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; DWORD dwCreationDistribution = 0; DWORD dwFlagsAndAttributes = 0; + int mode; + va_list arg; - if (( _oflag & S_IREAD ) == S_IREAD) - dwShareMode = FILE_SHARE_READ; - else if ( ( _oflag & S_IWRITE) == S_IWRITE ) { - dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; - } + va_start (arg, _oflag); + mode = va_arg(arg,int); + va_end (arg); + if ( (mode == S_IWRITE) || (mode == 0) ) + dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY; /* * @@ -68,16 +71,10 @@ int _open(const char *_path, int _oflag,...) */ if (( _oflag & _O_RDWR ) == _O_RDWR ) dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ ; - else if (( _oflag & O_RDONLY ) == O_RDONLY ) - dwDesiredAccess |= GENERIC_READ ; else if (( _oflag & _O_WRONLY ) == _O_WRONLY ) dwDesiredAccess |= GENERIC_WRITE ; - - if (( _oflag & S_IREAD ) == S_IREAD ) - dwShareMode |= FILE_SHARE_READ; - - if (( _oflag & S_IWRITE ) == S_IWRITE ) - dwShareMode |= FILE_SHARE_WRITE; + else + dwDesiredAccess |= GENERIC_READ ; if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) ) dwCreationDistribution |= CREATE_NEW; @@ -151,10 +148,12 @@ __fileno_alloc(HANDLE hFile, int mode) fileno_modes_type *old_fileno_modes = fileno_modes; maxfno += 255; fileno_modes = (fileno_modes_type *)malloc(maxfno * sizeof(fileno_modes_type)); - if ( old_fileno_modes != NULL ) - memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type)); + if ( old_fileno_modes != NULL ) + { + memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type)); + free ( old_fileno_modes ); + } memset(fileno_modes + oldcount, 0, (maxfno-oldcount)*sizeof(fileno_modes)); - free ( old_fileno_modes ); }