JDK-6631353 : Simplify io_util_md.c handleLseek using SetFilePointerEx (win)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2007-11-17
  • Updated: 2012-01-08
  • Resolved: 2012-01-08
Related Reports
Relates :  
Relates :  
Description
The implementation of io_util_md.c handleLseek
can be simplified and sped up a bit using the Microsoft-recommended
SetFilePointerEx instead of SetFilePointer

Comments
EVALUATION The code was changed to use SetFilePointerEx as part of the changes to 6402006.
08-01-2012

EVALUATION Probably worth doing, but only if changes are made throughout the JDK, replacing SetFilePointer and GetFileSize, etc. with their Ex counterparts.
18-11-2007

EVALUATION Indeed. @@ -535,28 +542,14 @@ jlong handleLseek(jlong fd, jlong offset, jint whence) { - DWORD lowPos = 0; - long highPos = 0; - DWORD op = FILE_CURRENT; - HANDLE h = (HANDLE)fd; - - if (whence == SEEK_END) { - op = FILE_END; - } - if (whence == SEEK_CUR) { - op = FILE_CURRENT; - } - if (whence == SEEK_SET) { - op = FILE_BEGIN; - } - - lowPos = (DWORD)offset; - highPos = (long)(offset >> 32); - lowPos = SetFilePointer(h, lowPos, &highPos, op); - if (lowPos == ((DWORD)-1)) { - if (GetLastError() != ERROR_SUCCESS) { + LARGE_INTEGER li; + const DWORD moveMethod = ((whence == SEEK_SET) ? FILE_BEGIN : + (whence == SEEK_CUR) ? FILE_CURRENT : + (whence == SEEK_END) ? FILE_END : + -1 ); + li.QuadPart = offset; + if (SetFilePointerEx((HANDLE) fd, li, &li, moveMethod) == 0) return -1; - } - } - return (((jlong)highPos) << 32) | lowPos; + + return li.QuadPart; }
17-11-2007