changeset 29228:dfa75715dfa7

8055915: (ch) FileDispatcherImpl.truncate0 should use SetFileInformationByHandle [win] Reviewed-by: alanb
author igerasim
date Mon, 02 Mar 2015 11:07:47 +0300
parents 2ef8d6233715
children 522667854295
files jdk/src/java.base/windows/native/libnio/ch/FileDispatcherImpl.c
diffstat 1 files changed, 7 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/windows/native/libnio/ch/FileDispatcherImpl.c	Mon Mar 02 11:48:08 2015 +0900
+++ b/jdk/src/java.base/windows/native/libnio/ch/FileDispatcherImpl.c	Mon Mar 02 11:07:47 2015 +0300
@@ -325,17 +325,14 @@
 {
     BOOL result = 0;
     HANDLE h = (HANDLE)(handleval(env, fdo));
-    LARGE_INTEGER offset;
+    FILE_END_OF_FILE_INFO eofInfo;
 
-    offset.QuadPart = size;
-    result = SetFilePointerEx(h, offset, NULL, FILE_BEGIN);
-    if (result == 0) {
-        JNU_ThrowIOExceptionWithLastError(env, "Truncation failed");
-        return IOS_THROWN;
-    }
-
-    result = SetEndOfFile(h);
-    if (result == 0) {
+    eofInfo.EndOfFile.QuadPart = size;
+    result = SetFileInformationByHandle(h,
+                                        FileEndOfFileInfo,
+                                        &eofInfo,
+                                        sizeof(eofInfo));
+    if (result == FALSE) {
         JNU_ThrowIOExceptionWithLastError(env, "Truncation failed");
         return IOS_THROWN;
     }