Commit 410db2ad authored by Alexandre Julliard's avatar Alexandre Julliard

Rewrote SetFilePointer to use SetFilePointerEx.

parent e937e469
......@@ -815,48 +815,22 @@ BOOL WINAPI SetEndOfFile( HANDLE hFile )
/***********************************************************************
* SetFilePointer (KERNEL32.@)
*/
DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword,
DWORD method )
DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword, DWORD method )
{
static const int whence[3] = { SEEK_SET, SEEK_CUR, SEEK_END };
DWORD ret = INVALID_SET_FILE_POINTER;
NTSTATUS status;
int fd;
TRACE("handle %p offset %ld high %ld origin %ld\n",
hFile, distance, highword?*highword:0, method );
LARGE_INTEGER dist, newpos;
if (method > FILE_END)
if (highword)
{
SetLastError( ERROR_INVALID_PARAMETER );
return ret;
dist.u.LowPart = distance;
dist.u.HighPart = *highword;
}
else dist.QuadPart = distance;
if (!(status = wine_server_handle_to_fd( hFile, 0, &fd, NULL, NULL )))
{
off_t pos, res;
if (highword) pos = ((off_t)*highword << 32) | (ULONG)distance;
else pos = (off_t)distance;
if ((res = lseek( fd, pos, whence[method] )) == (off_t)-1)
{
/* also check EPERM due to SuSE7 2.2.16 lseek() EPERM kernel bug */
if (((errno == EINVAL) || (errno == EPERM)) && (method != FILE_BEGIN) && (pos < 0))
SetLastError( ERROR_NEGATIVE_SEEK );
else
FILE_SetDosError();
}
else
{
ret = (DWORD)res;
if (highword) *highword = (res >> 32);
if (ret == INVALID_SET_FILE_POINTER) SetLastError( 0 );
}
wine_server_release_fd( hFile, fd );
}
else SetLastError( RtlNtStatusToDosError(status) );
if (!SetFilePointerEx( hFile, dist, &newpos, method )) return INVALID_SET_FILE_POINTER;
return ret;
if (highword) *highword = newpos.u.HighPart;
if (newpos.u.LowPart == INVALID_SET_FILE_POINTER) SetLastError( 0 );
return newpos.u.LowPart;
}
......
......@@ -1621,6 +1621,7 @@ BOOL WINAPI SetEvent(HANDLE);
VOID WINAPI SetFileApisToANSI(void);
VOID WINAPI SetFileApisToOEM(void);
DWORD WINAPI SetFilePointer(HANDLE,LONG,LPLONG,DWORD);
BOOL WINAPI SetFilePointerEx(HANDLE,LARGE_INTEGER,LARGE_INTEGER*,DWORD);
BOOL WINAPI SetFileSecurityA(LPCSTR,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
BOOL WINAPI SetFileSecurityW(LPCWSTR,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
#define SetFileSecurity WINELIB_NAME_AW(SetFileSecurity)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment