Author: dchapyshev
Date: Sat Dec 20 02:02:25 2008
New Revision: 38191
URL:
http://svn.reactos.org/svn/reactos?rev=38191&view=rev
Log:
- Fix 2 winetests
Modified:
trunk/reactos/dll/win32/kernel32/file/lfile.c
Modified: trunk/reactos/dll/win32/kernel32/file/lfile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/lf…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/lfile.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/lfile.c [iso-8859-1] Sat Dec 20 02:02:25 2008
@@ -28,8 +28,8 @@
DWORD NumberOfBytesRead;
if ( !ReadFile(
- (HANDLE) hFile,
- (LPVOID) lpBuffer,
+ LongToHandle(hFile),
+ lpBuffer,
(DWORD) lBytes,
& NumberOfBytesRead,
NULL) )
@@ -84,34 +84,42 @@
int iReadWrite
)
{
- DWORD dwAccessMask = 0;
- DWORD dwShareMode = 0;
+ DWORD dwAccess, dwSharing, dwCreation;
- if ( (iReadWrite & OF_READWRITE ) == OF_READWRITE )
- dwAccessMask = GENERIC_READ | GENERIC_WRITE;
- else if ( (iReadWrite & OF_READ ) == OF_READ )
- dwAccessMask = GENERIC_READ;
- else if ( (iReadWrite & OF_WRITE ) == OF_WRITE )
- dwAccessMask = GENERIC_WRITE;
+ if (iReadWrite & OF_CREATE)
+ {
+ dwCreation = CREATE_ALWAYS;
+ dwAccess = GENERIC_READ | GENERIC_WRITE;
+ }
+ else
+ {
+ dwCreation = OPEN_EXISTING;
+ switch(iReadWrite & 0x03)
+ {
+ case OF_READ: dwAccess = GENERIC_READ; break;
+ case OF_WRITE: dwAccess = GENERIC_WRITE; break;
+ case OF_READWRITE: dwAccess = GENERIC_READ | GENERIC_WRITE; break;
+ default: dwAccess = 0; break;
+ }
+ }
- 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;
- 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;
+ switch(iReadWrite & 0x70)
+ {
+ case OF_SHARE_EXCLUSIVE: dwSharing = 0; break;
+ case OF_SHARE_DENY_WRITE: dwSharing = FILE_SHARE_READ; break;
+ case OF_SHARE_DENY_READ: dwSharing = FILE_SHARE_WRITE; break;
+ case OF_SHARE_DENY_NONE:
+ case OF_SHARE_COMPAT:
+ default: dwSharing = FILE_SHARE_READ | FILE_SHARE_WRITE; break;
+ }
- return (HFILE) CreateFileA(
- lpPathName,
- dwAccessMask,
- dwShareMode,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
+ return (HFILE) CreateFileA(lpPathName,
+ dwAccess,
+ dwSharing,
+ NULL,
+ dwCreation,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
}
@@ -125,15 +133,18 @@
int iAttribute
)
{
- iAttribute &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN |
FILE_ATTRIBUTE_SYSTEM;
- return (HFILE) CreateFileA(
- lpPathName,
- GENERIC_READ | GENERIC_WRITE,
- (FILE_SHARE_READ | FILE_SHARE_WRITE),
- NULL,
- CREATE_ALWAYS,
- iAttribute,
- NULL);
+ HANDLE hFile;
+
+ iAttribute &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN |
FILE_ATTRIBUTE_SYSTEM;
+ hFile = CreateFileA(lpPathName,
+ GENERIC_READ | GENERIC_WRITE,
+ (FILE_SHARE_READ | FILE_SHARE_WRITE),
+ NULL,
+ CREATE_ALWAYS,
+ iAttribute,
+ NULL);
+
+ return HandleToLong(hFile);
}
@@ -146,11 +157,7 @@
HFILE hFile
)
{
- if (CloseHandle ((HANDLE)hFile))
- {
- return 0;
- }
- return HFILE_ERROR;
+ return CloseHandle(LongToHandle(hFile)) ? 0 : HFILE_ERROR;
}
@@ -165,11 +172,10 @@
int iOrigin
)
{
- return SetFilePointer (
- (HANDLE) hFile,
- lOffset,
- NULL,
- (DWORD) iOrigin);
+ return SetFilePointer(LongToHandle(hFile),
+ lOffset,
+ NULL,
+ (DWORD) iOrigin);
}
/* EOF */