minor corrections to match the behavior of wine's implementation
Modified: trunk/reactos/lib/kernel32/file/lfile.c
_____
Modified: trunk/reactos/lib/kernel32/file/lfile.c
--- trunk/reactos/lib/kernel32/file/lfile.c 2005-05-06 10:45:24 UTC
(rev 15036)
+++ trunk/reactos/lib/kernel32/file/lfile.c 2005-05-06 11:02:47 UTC
(rev 15037)
@@ -28,15 +28,14 @@
{
DWORD NumberOfBytesRead;
- if (ReadFile(
+ if ( !ReadFile(
(HANDLE) hFile,
(LPVOID) lpBuffer,
(DWORD) lBytes,
& NumberOfBytesRead,
- NULL
- ) == FALSE)
+ NULL) )
{
- return -1;
+ return HFILE_ERROR;
}
return NumberOfBytesRead;
}
@@ -57,21 +56,20 @@
if (lBytes == 0)
{
- if ( SetEndOfFile((HANDLE) hFile ) == FALSE )
+ if ( !SetEndOfFile((HANDLE) hFile ) )
{
- return -1;
+ return HFILE_ERROR;
}
return 0;
}
- if ( WriteFile(
+ if ( !WriteFile(
(HANDLE) hFile,
(LPVOID) lpBuffer,
(DWORD) lBytes,
& NumberOfBytesWritten,
- NULL
- ) == FALSE )
+ NULL) )
{
- return -1;
+ return HFILE_ERROR;
}
return NumberOfBytesWritten;
}
@@ -97,16 +95,15 @@
else if ( (iReadWrite & OF_WRITE ) == OF_WRITE )
dwAccessMask = GENERIC_WRITE;
- if ((iReadWrite & OF_SHARE_COMPAT) == OF_SHARE_COMPAT )
- dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ |
FILE_SHARE_DELETE;
- else if ((iReadWrite & OF_SHARE_DENY_NONE) ==
OF_SHARE_DENY_NONE)
- dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_READ |
FILE_SHARE_DELETE;
- else if ((iReadWrite & OF_SHARE_DENY_READ) ==
OF_SHARE_DENY_READ)
- dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+ if ((iReadWrite & OF_SHARE_DENY_READ) == OF_SHARE_DENY_READ)
+ dwShareMode = FILE_SHARE_WRITE;
else if ((iReadWrite & OF_SHARE_DENY_WRITE) ==
OF_SHARE_DENY_WRITE )
- dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;
+ dwShareMode = FILE_SHARE_READ;
else if ((iReadWrite & OF_SHARE_EXCLUSIVE) ==
OF_SHARE_EXCLUSIVE)
dwShareMode = 0;
+ else
+ /* OF_SHARE_DENY_NONE, OF_SHARE_COMPAT and everything
else */
+ dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
return (HFILE) CreateFileA(
lpPathName,
@@ -129,13 +126,14 @@
int iAttribute
)
{
+ iAttribute &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN |
FILE_ATTRIBUTE_SYSTEM;
return (HFILE) CreateFileA(
lpPathName,
- GENERIC_ALL,
+ GENERIC_READ | GENERIC_WRITE,
(FILE_SHARE_READ | FILE_SHARE_WRITE),
NULL,
CREATE_ALWAYS,
- iAttribute & FILE_ATTRIBUTE_VALID_FLAGS,
+ iAttribute,
NULL);
}
@@ -153,7 +151,7 @@
{
return 0;
}
- return -1;
+ return HFILE_ERROR;
}