From 1bc72fb6da2e86c2323de6273034580882059e67 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 22 Aug 2007 11:55:01 +0200 Subject: [PATCH] cabinet: Use the correct create disposition in fdi_open. --- dlls/cabinet/cabinet_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dlls/cabinet/cabinet_main.c b/dlls/cabinet/cabinet_main.c index 4cea2a1eb2a..6483a3f36d7 100644 --- a/dlls/cabinet/cabinet_main.c +++ b/dlls/cabinet/cabinet_main.c @@ -84,7 +84,7 @@ static INT_PTR fdi_open(char *pszFile, int oflag, int pmode) HANDLE handle; DWORD dwAccess = 0; DWORD dwShareMode = 0; - DWORD dwCreateDisposition = OPEN_EXISTING; + DWORD dwCreateDisposition; switch (oflag & _O_ACCMODE) { @@ -102,10 +102,17 @@ static INT_PTR fdi_open(char *pszFile, int oflag, int pmode) break; } - if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES) - dwCreateDisposition = OPEN_EXISTING; + if (oflag & _O_CREAT) + { + dwCreateDisposition = OPEN_ALWAYS; + if (oflag & _O_EXCL) dwCreateDisposition = CREATE_NEW; + else if (oflag & _O_TRUNC) dwCreateDisposition = CREATE_ALWAYS; + } else - dwCreateDisposition = CREATE_NEW; + { + dwCreateDisposition = OPEN_EXISTING; + if (oflag & _O_TRUNC) dwCreateDisposition = TRUNCATE_EXISTING; + } handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL, dwCreateDisposition, 0, NULL); -- 2.11.4.GIT