SetFilePointerEx take 2
Rob Crittenden <[email protected]> Fri, 30 Jun 2006 11:33:16 -0400
| Newsgroups | gmane.comp.emulators.winex.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------070702090608070507010503
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
I reimplemented SetFilePointerEx() so it makes the wineserver call
instead of SetFilePointer(). Now SFP calls SFPE.
In my first patch I forgot to update include/winbase.h with a
declaration of SFPE. That is added in this patch.
The source of the test program I used is at
http://www.greyoak.com/winex/setfile.cpp. I updated it to inclulde a
couple of odd cases and also test SFP directly.
I tested this with a 2.7GB file, so large numbers work ok.
rob
--------------070702090608070507010503
Content-Type: text/x-diff;
name="setfile2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="setfile2.diff"
Index: include/winbase.h
===================================================================
RCS file: /cvsroot/winex/include/winbase.h,v
retrieving revision 1.33
diff -r1.33 winbase.h
1483a1484
> BOOL WINAPI SetFilePointerEx(HANDLE,LARGE_INTEGER,PLARGE_INTEGER,DWORD);
Index: files/file.c
===================================================================
RCS file: /cvsroot/winex/files/file.c,v
retrieving revision 1.32
diff -r1.32 file.c
2048c2048
< DWORD ret = 0xffffffff;
---
> LARGE_INTEGER newdistance, newpos;
2053,2068c2053,2061
< SERVER_START_REQ( set_file_pointer )
< {
< req->handle = hFile;
< req->low = distance;
< req->high = highword ? *highword : (distance >= 0) ? 0 : -1;
< /* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
< req->whence = method;
< SetLastError( 0 );
< if (!wine_server_call_err( req ))
< {
< ret = reply->new_low;
< if (highword) *highword = reply->new_high;
< }
< }
< SERVER_END_REQ;
< return ret;
---
> newdistance.u.LowPart = distance;
> newdistance.u.HighPart = highword ? *highword : (distance >= 0) ? 0 : -1;
>
> if (!SetFilePointerEx( hFile, newdistance, &newpos, method ))
> return INVALID_SET_FILE_POINTER;
>
> if (highword) *highword = newpos.u.HighPart;
>
> return newpos.u.LowPart;
2087,2091c2080,2096
< /* FIXME: might be better to have SetFilePointer call SetFilePointerEx,
< but in that case, we might also want to modify the wineserver request */
< liDistanceToMove.u.LowPart = SetFilePointer(hFile,
< liDistanceToMove.u.LowPart, &liDistanceToMove.u.HighPart,
< dwMoveMethod);
---
> SERVER_START_REQ( set_file_pointer )
> {
> req->handle = hFile;
> req->low = liDistanceToMove.u.LowPart;
> req->high = liDistanceToMove.u.HighPart;
> /* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
> req->whence = dwMoveMethod;
> SetLastError( 0 );
> if (!wine_server_call_err( req ))
> {
> if (lpNewFilePointer) {
> lpNewFilePointer->u.LowPart = reply->new_low;
> lpNewFilePointer->u.HighPart = reply->new_high;
> }
> }
> }
> SERVER_END_REQ;
2097,2101d2101
< if (lpNewFilePointer) {
< lpNewFilePointer->u.LowPart = liDistanceToMove.u.LowPart;
< lpNewFilePointer->u.HighPart = liDistanceToMove.u.HighPart;
< }
<
--------------070702090608070507010503--