[newlib-cygwin] Cygwin: disk device: stop using SetFilePointer

Corinna Vinschen corinna@sourceware.org
Sat Feb 9 17:42:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=52d91f112ec2e5dd62edd200ca547bb11e52effa

commit 52d91f112ec2e5dd62edd200ca547bb11e52effa
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Sat Feb 9 18:41:47 2019 +0100

    Cygwin: disk device: stop using SetFilePointer
    
    This is a really old and crappy API, as the previous commit shows.
    Use NtQueryInformationFile(FilePositionInformation) here instead.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler_floppy.cc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc
index cca00ba..43139ac 100644
--- a/winsup/cygwin/fhandler_floppy.cc
+++ b/winsup/cygwin/fhandler_floppy.cc
@@ -384,9 +384,12 @@ fhandler_dev_floppy::dup (fhandler_base *child, int flags)
 inline off_t
 fhandler_dev_floppy::get_current_position ()
 {
-  LARGE_INTEGER off = { QuadPart: 0LL };
-  off.LowPart = SetFilePointer (get_handle (), 0, &off.HighPart, FILE_CURRENT);
-  return off.QuadPart;
+  IO_STATUS_BLOCK io;
+  FILE_POSITION_INFORMATION fpi = { { QuadPart : 0LL } };
+
+  NtQueryInformationFile (get_handle (), &io, &fpi, sizeof fpi,
+			  FilePositionInformation);
+  return fpi.CurrentByteOffset.QuadPart;
 }
 
 void __reg3



More information about the Cygwin-cvs mailing list