cabinet: Use the correct create disposition in fdi_open.

This commit is contained in:
Alexandre Julliard 2007-08-22 11:55:01 +02:00
parent d5ff728265
commit 1bc72fb6da
1 changed files with 11 additions and 4 deletions

View File

@ -84,7 +84,7 @@ static INT_PTR fdi_open(char *pszFile, int oflag, int pmode)
HANDLE handle; HANDLE handle;
DWORD dwAccess = 0; DWORD dwAccess = 0;
DWORD dwShareMode = 0; DWORD dwShareMode = 0;
DWORD dwCreateDisposition = OPEN_EXISTING; DWORD dwCreateDisposition;
switch (oflag & _O_ACCMODE) switch (oflag & _O_ACCMODE)
{ {
@ -102,10 +102,17 @@ static INT_PTR fdi_open(char *pszFile, int oflag, int pmode)
break; break;
} }
if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES) if (oflag & _O_CREAT)
dwCreateDisposition = OPEN_EXISTING; {
dwCreateDisposition = OPEN_ALWAYS;
if (oflag & _O_EXCL) dwCreateDisposition = CREATE_NEW;
else if (oflag & _O_TRUNC) dwCreateDisposition = CREATE_ALWAYS;
}
else else
dwCreateDisposition = CREATE_NEW; {
dwCreateDisposition = OPEN_EXISTING;
if (oflag & _O_TRUNC) dwCreateDisposition = TRUNCATE_EXISTING;
}
handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL, handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
dwCreateDisposition, 0, NULL); dwCreateDisposition, 0, NULL);