changeset in /hg/icedtea6: Ensure NIO2 is in sync with the lates...

Andrew John Hughes ahughes at redhat.com
Thu Feb 5 11:03:38 PST 2009


changeset 9923df826001 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=9923df826001
description:
	Ensure NIO2 is in sync with the latest build drop, b98.

	2009-02-05  Andrew John Hughes  <ahughes at redhat.com>

		Ensure the NIO2 code is in sync with the latest
		build drop, b98.
		* overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView.java,
		* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java,
		* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/Cancellable.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsAclFileAttributeView.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileCopy.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsNamedAttributeView.java,
		* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsPath.java,
		* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/InterruptCopy.java,
		* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView/Basic.java,

diffstat:

16 files changed, 467 insertions(+), 328 deletions(-)
ChangeLog                                                                                                         |   20 
overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView.java |   12 
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java                            |   55 +-
overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/Cancellable.java                                           |   11 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsAclFileAttributeView.java                         |   13 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java                               |  220 +++++-----
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java                              |   18 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java                           |    4 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileCopy.java                                     |   21 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java                                    |    4 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java                           |    3 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java                                  |   16 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsNamedAttributeView.java                           |   18 
overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsPath.java                                         |  220 +++++-----
overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/InterruptCopy.java                        |    4 
overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView/Basic.java        |  156 +++++--

diffs (truncated from 1256 to 500 lines):

diff -r b0be146027ad -r 9923df826001 ChangeLog
--- a/ChangeLog	Wed Feb 04 12:48:30 2009 +0000
+++ b/ChangeLog	Thu Feb 05 19:03:06 2009 +0000
@@ -1,3 +1,23 @@ 2009-02-04  Andrew John Hughes  <ahughes
+2009-02-05  Andrew John Hughes  <ahughes at redhat.com>
+
+	Ensure the NIO2 code is in sync with the latest
+	build drop, b98.
+	* overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView.java,
+	* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java,
+	* overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/Cancellable.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsAclFileAttributeView.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileCopy.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsNamedAttributeView.java,
+	* overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsPath.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/Path/InterruptCopy.java,
+	* overlays/nio2/openjdk/jdk/test/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView/Basic.java,
+
 2009-02-04  Andrew John Hughes  <ahughes at redhat.com>
 
 	* acinclude.m4:
diff -r b0be146027ad -r 9923df826001 overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView.java
--- a/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView.java	Wed Feb 04 12:48:30 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/org/classpath/icedtea/java/nio/file/attribute/NamedAttributeView.java	Thu Feb 05 19:03:06 2009 +0000
@@ -48,9 +48,6 @@ import java.io.IOException;
  * intended for use where the size of an attribute value is larger than {@link
  * Integer#MAX_VALUE}.
  *
- * <p> {@note There has been feedback that the read/write methods should use byte
- * arrays instead of ByteBuffers.}
- *
  * <p> Named attributes may be used in some implementations to store security
  * related attributes so consequently, in the case of the default provider at
  * least, all methods that access named attributes require the
@@ -64,13 +61,10 @@ import java.io.IOException;
  * <p> Where dynamic access to file attributes is required, the {@link
  * #getAttribute getAttribute} or {@link #readAttributes(String,String[])
  * readAttributes(String,String[])} methods may be used to read the attribute
- * value as if by invoking the {@link #read read} method. Upon return, the
- * buffer's {@link ByteBuffer#position position} is the index of the first
- * byte of the attribute value, and its {@link ByteBuffer#limit limit} is
- * the index of the first byte that should not be read. The {@link
+ * value. The attribute value is returned as a byte array (byte[]). The {@link
  * #setAttribute setAttribute} method may be used to write the value of a
- * user-defined/named attribute from a buffer as if by invoking the {@link
- * #write write} method.
+ * user-defined/named attribute from a buffer (as if by invoking the {@link
+ * #write write} method), or byte array (byte[]).
  *
  * @since 1.7
  */
diff -r b0be146027ad -r 9923df826001 overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java	Wed Feb 04 12:48:30 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/AbstractNamedAttributeView.java	Thu Feb 05 19:03:06 2009 +0000
@@ -62,18 +62,31 @@ abstract class AbstractNamedAttributeVie
 
 
     public final Object getAttribute(String attribute) throws IOException {
-        int size = size(attribute);
-        ByteBuffer buf = ByteBuffer.allocate(size);
-        read(attribute, buf);
-        buf.flip();
-        return buf;
+         int size;
+         try {
+             size = size(attribute);
+         } catch (IOException e) {
+             // not found or some other I/O error
+             if (list().contains(attribute))
+                 throw e;
+             return null;
+         }
+         byte[] buf = new byte[size];
+         int n = read(attribute, ByteBuffer.wrap(buf));
+         return (n == size) ? buf : Arrays.copyOf(buf, n);
     }
 
 
     public final void setAttribute(String attribute, Object value)
         throws IOException
     {
-        write(attribute, (ByteBuffer)value);
+         ByteBuffer bb;
+         if (value instanceof byte[]) {
+             bb = ByteBuffer.wrap((byte[])value);
+         } else {
+             bb = (ByteBuffer)value;
+         }
+         write(attribute, bb);
     }
 
 
@@ -88,29 +101,23 @@ abstract class AbstractNamedAttributeVie
             readAll = true;
         } else {
             names.add(first);
-            for (String name: rest) {
-                if (name.equals("*")) {
-                    readAll = true;
-                    break;
-                }
+        }
+        for (String name: rest) {
+            if (name.equals("*")) {
+                readAll = true;
+            } else {
                 names.add(name);
             }
         }
-        if (readAll) {
-            names.clear();
-            for (String name: list()) {
-                names.add(name);
-            }
-        }
+        if (readAll)
+            names = list();
 
-        // allocate buffer for each value and return as map
-        Map<String,ByteBuffer> result = new HashMap<String,ByteBuffer>();
+        // read each value and return in map
+        Map<String,Object> result = new HashMap<String,Object>();
         for (String name: names) {
-            int size = size(name);
-            ByteBuffer buf = ByteBuffer.allocate(size);
-            read(name, buf);
-            result.put(name, buf);
-            buf.flip();
+            Object value = getAttribute(name);
+            if (value != null)
+                result.put(name, value);
         }
 
         return result;
diff -r b0be146027ad -r 9923df826001 overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/Cancellable.java
--- a/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/Cancellable.java	Wed Feb 04 12:48:30 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/share/classes/sun/nio/fs/Cancellable.java	Thu Feb 05 19:03:06 2009 +0000
@@ -112,21 +112,24 @@ abstract class Cancellable implements Ru
     abstract void implRun() throws Throwable;
 
     /**
-     * Invokes the task in its own thread. If this (meaning the current) thread
-     * is interrupted then an attempt is make to cancel the background task by
-     * writting bits into the memory location that it is polling. On return,
-     * the interrupt status for this thread has been cleared.
+     * Invokes the given task in its own thread. If this (meaning the current)
+     * thread is interrupted then an attempt is make to cancel the background
+     * thread by writing into the memory location that it polls cooperatively.
      */
     static void runInterruptibly(Cancellable task) throws ExecutionException {
         Thread t = new Thread(task);
         t.start();
+        boolean cancelledByInterrupt = false;
         while (t.isAlive()) {
             try {
                 t.join();
             } catch (InterruptedException e) {
+                cancelledByInterrupt = true;
                 task.cancel();
             }
         }
+        if (cancelledByInterrupt)
+            Thread.currentThread().interrupt();
         Throwable exc = task.exception();
         if (exc != null)
             throw new ExecutionException(exc);
diff -r b0be146027ad -r 9923df826001 overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsAclFileAttributeView.java
--- a/overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsAclFileAttributeView.java	Wed Feb 04 12:48:30 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsAclFileAttributeView.java	Thu Feb 05 19:03:06 2009 +0000
@@ -117,8 +117,7 @@ class WindowsAclFileAttributeView
 
         // GetFileSecurity does not follow links so when following links we
         // need the final target
-        String path = followLinks ? WindowsLinkSupport.getFinalPath(file) :
-                                    file.getPathForWin32Calls();
+        String path = WindowsLinkSupport.getFinalPath(file, followLinks);
         NativeBuffer buffer = getFileSecurity(path, OWNER_SECURITY_INFORMATION);
         try {
             // get the address of the SID
@@ -142,8 +141,7 @@ class WindowsAclFileAttributeView
 
         // GetFileSecurity does not follow links so when following links we
         // need the final target
-        String path = followLinks ? WindowsLinkSupport.getFinalPath(file) :
-                                    file.getPathForWin32Calls();
+        String path = WindowsLinkSupport.getFinalPath(file, followLinks);
 
         // ALLOW and DENY entries in DACL;
         // AUDIT entries in SACL (ignore for now as it requires privileges)
@@ -170,8 +168,7 @@ class WindowsAclFileAttributeView
 
         // SetFileSecurity does not follow links so when following links we
         // need the final target
-        String path = followLinks ? WindowsLinkSupport.getFinalPath(file) :
-                                    file.getPathForWin32Calls();
+        String path = WindowsLinkSupport.getFinalPath(file, followLinks);
 
         // ConvertStringSidToSid allocates memory for SID so must invoke
         // LocalFree to free it when we are done
@@ -216,9 +213,7 @@ class WindowsAclFileAttributeView
 
         // SetFileSecurity does not follow links so when following links we
         // need the final target
-        String path = followLinks ? WindowsLinkSupport.getFinalPath(file) :
-                                    file.getPathForWin32Calls();
-
+        String path = WindowsLinkSupport.getFinalPath(file, followLinks);
         WindowsSecurityDescriptor sd = WindowsSecurityDescriptor.create(acl);
         try {
             SetFileSecurity(path, DACL_SECURITY_INFORMATION, sd.address());
diff -r b0be146027ad -r 9923df826001 overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
--- a/overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java	Wed Feb 04 12:48:30 2009 +0000
+++ b/overlays/nio2/openjdk/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java	Thu Feb 05 19:03:06 2009 +0000
@@ -56,7 +56,76 @@ class WindowsChannelFactory {
      * Do not follow reparse points when opening an existing file. Do not fail
      * if the file is a reparse point.
      */
-    static final OpenOption NOFOLLOW_REPARSEPOINT = new OpenOption() { };
+    static final OpenOption OPEN_REPARSE_POINT = new OpenOption() { };
+
+    /**
+     * Represents the flags from a user-supplied set of open options.
+     */
+    private static class Flags {
+        boolean read;
+        boolean write;
+        boolean append;
+        boolean truncateExisting;
+        boolean create;
+        boolean createNew;
+        boolean deleteOnClose;
+        boolean sparse;
+        boolean overlapped;
+        boolean sync;
+        boolean dsync;
+
+        // non-standard
+        boolean shareRead = true;
+        boolean shareWrite = true;
+        boolean shareDelete = true;
+        boolean noFollowLinks;
+        boolean openReparsePoint;
+
+        static Flags toFlags(Set<? extends OpenOption> options) {
+            Flags flags = new Flags();
+            for (OpenOption option: options) {
+                if (!(option instanceof StandardOpenOption)) {
+                    if (option == ExtendedOpenOption.NOSHARE_READ) {
+                        flags.shareRead = false;
+                        continue;
+                    }
+                    if (option == ExtendedOpenOption.NOSHARE_WRITE) {
+                        flags.shareWrite = false;
+                        continue;
+                    }
+                    if (option == ExtendedOpenOption.NOSHARE_DELETE) {
+                        flags.shareDelete = false;
+                        continue;
+                    }
+                    if (option == LinkOption.NOFOLLOW_LINKS) {
+                        flags.noFollowLinks = true;
+                        continue;
+                    }
+                    if (option == OPEN_REPARSE_POINT) {
+                        flags.openReparsePoint = true;
+                        continue;
+                    }
+                    if (option == null)
+                        throw new NullPointerException();
+                    throw new UnsupportedOperationException("Unsupported open option");
+                }
+                switch ((StandardOpenOption)option) {
+                    case READ : flags.read = true; break;
+                    case WRITE : flags.write = true; break;
+                    case APPEND : flags.append = true; break;
+                    case TRUNCATE_EXISTING : flags.truncateExisting = true; break;
+                    case CREATE : flags.create = true; break;
+                    case CREATE_NEW : flags.createNew = true; break;
+                    case DELETE_ON_CLOSE : flags.deleteOnClose = true; break;
+                    case SPARSE : flags.sparse = true; break;
+                    case SYNC : flags.sync = true; break;
+                    case DSYNC : flags.dsync = true; break;
+                    default: throw new AssertionError("Should not get here");
+                }
+            }
+            return flags;
+        }
+    }
 
     /**
      * Open/creates file, returning FileChannel to access the file
@@ -72,50 +141,25 @@ class WindowsChannelFactory {
                                       long pSecurityDescriptor)
         throws WindowsException
     {
-        boolean reading = false;
-        boolean writing = false;
-        boolean append = false;
-        boolean trunc = false;
-
-        // check for invalid flags
-        for (OpenOption flag: options) {
-            if (flag == StandardOpenOption.READ) {
-                reading = true; continue;
-            }
-            if (flag == StandardOpenOption.WRITE) {
-                writing = true; continue;
-            }
-            if (flag == StandardOpenOption.APPEND) {
-                append = true;
-                writing = true;
-                continue;
-            }
-            if (flag == StandardOpenOption.TRUNCATE_EXISTING) {
-                trunc = true; continue;
-            }
-            if (flag == null)
-                throw new NullPointerException();
-            if (!(flag instanceof StandardOpenOption) &&
-                !(flag instanceof ExtendedOpenOption))
-            {
-                throw new UnsupportedOperationException("Unsupported open option");
-            }
-        }
-
-        // default is reading
-        if (!reading && !writing) {
-            reading = true;
-        }
-
-        // check for invalid combinations
-        if (reading && append)
+        Flags flags = Flags.toFlags(options);
+
+        // default is reading; append => writing
+        if (!flags.read && !flags.write) {
+            if (flags.append) {
+                flags.write = true;
+            } else {
+                flags.read = true;
+            }
+        }
+
+        // validation
+        if (flags.read && flags.append)
             throw new IllegalArgumentException("READ + APPEND not allowed");
-        if (append && trunc)
+        if (flags.append && flags.truncateExisting)
             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 
-        FileDescriptor fdObj = open(pathForWindows, pathToCheck, reading, writing,
-            append, false, options, pSecurityDescriptor);
-        return FileChannelImpl.open(fdObj, reading, writing, null);
+        FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
+        return FileChannelImpl.open(fdObj, flags.read, flags.write, null);
     }
 
     /**
@@ -135,38 +179,24 @@ class WindowsChannelFactory {
                                                               ThreadPool pool)
         throws IOException
     {
-        boolean reading = false;
-        boolean writing = false;
-
-        // check for invalid flags
-        for (OpenOption flag: options) {
-            if (flag == StandardOpenOption.READ) {
-                reading = true; continue;
-            }
-            if (flag == StandardOpenOption.WRITE) {
-                writing = true; continue;
-            }
-            if (flag == null)
-                throw new NullPointerException();
-            if (!(flag instanceof StandardOpenOption) &&
-                !(flag instanceof ExtendedOpenOption))
-            {
-                throw new UnsupportedOperationException("Unsupported open option");
-            }
-            if (flag == StandardOpenOption.APPEND)
-                throw new UnsupportedOperationException("'APPEND' not supported");
-        }
+        Flags flags = Flags.toFlags(options);
+
+        // Overlapped I/O required
+        flags.overlapped = true;
 
         // default is reading
-        if (!reading && !writing) {
-            reading = true;
-        }
+        if (!flags.read && !flags.write) {
+            flags.read = true;
+        }
+
+        // validation
+        if (flags.append)
+            throw new UnsupportedOperationException("APPEND not allowed");
 
         // open file for overlapped I/O
         FileDescriptor fdObj;
         try {
-            fdObj = open(pathForWindows, pathToCheck, reading, writing, false,
-                         true, options, pSecurityDescriptor);
+            fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
         } catch (WindowsException x) {
             x.rethrowAsIOException(pathForWindows);
             return null;
@@ -174,7 +204,7 @@ class WindowsChannelFactory {
 
         // create the AsynchronousFileChannel
         try {
-            return WindowsAsynchronousFileChannelImpl.open(fdObj, reading, writing, pool);
+            return WindowsAsynchronousFileChannelImpl.open(fdObj, flags.read, flags.write, pool);
         } catch (IOException x) {
             // IOException is thrown if the file handle cannot be associated
             // with the completion port. All we can do is close the file.
@@ -190,11 +220,7 @@ class WindowsChannelFactory {
      */
     private static FileDescriptor open(String pathForWindows,
                                        String pathToCheck,
-                                       boolean reading,
-                                       boolean writing,
-                                       boolean append,
-                                       boolean overlapped,
-                                       Set<? extends OpenOption> options,
+                                       Flags flags,
                                        long pSecurityDescriptor)
         throws WindowsException
     {
@@ -203,30 +229,30 @@ class WindowsChannelFactory {
 
         // map options
         int dwDesiredAccess = 0;
-        if (reading)
+        if (flags.read)
             dwDesiredAccess |= GENERIC_READ;
-        if (writing)
-            dwDesiredAccess |= (append) ? FILE_APPEND_DATA : GENERIC_WRITE;
+        if (flags.write)
+            dwDesiredAccess |= (flags.append) ? FILE_APPEND_DATA : GENERIC_WRITE;
 
         int dwShareMode = 0;
-        if (!options.contains(ExtendedOpenOption.NOSHARE_READ))
+        if (flags.shareRead)
             dwShareMode |= FILE_SHARE_READ;
-        if (!options.contains(ExtendedOpenOption.NOSHARE_WRITE))
+        if (flags.shareWrite)
             dwShareMode |= FILE_SHARE_WRITE;
-        if (!options.contains(ExtendedOpenOption.NOSHARE_DELETE))
+        if (flags.shareDelete)
             dwShareMode |= FILE_SHARE_DELETE;
 
         int dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
         int dwCreationDisposition = OPEN_EXISTING;
-        if (writing) {
-            if (options.contains(StandardOpenOption.CREATE_NEW)) {
+        if (flags.write) {
+            if (flags.createNew) {
                 dwCreationDisposition = CREATE_NEW;
                 // force create to fail if file is orphaned reparse point
                 dwFlagsAndAttributes |= FILE_FLAG_OPEN_REPARSE_POINT;
             } else {
-                if (options.contains(StandardOpenOption.CREATE))
+                if (flags.create)
                     dwCreationDisposition = OPEN_ALWAYS;
-                if (options.contains(StandardOpenOption.TRUNCATE_EXISTING)) {
+                if (flags.truncateExisting) {
                     // Windows doesn't have a creation disposition that exactly
                     // corresponds to CREATE + TRUNCATE_EXISTING so we use
                     // the OPEN_ALWAYS mode and then truncate the file.
@@ -239,23 +265,21 @@ class WindowsChannelFactory {
             }
         }
 
-        if (options.contains(StandardOpenOption.DSYNC) || options.contains(StandardOpenOption.SYNC))
+        if (flags.dsync || flags.sync)
             dwFlagsAndAttributes |= FILE_FLAG_WRITE_THROUGH;
-        if (overlapped)
+        if (flags.overlapped)
             dwFlagsAndAttributes |= FILE_FLAG_OVERLAPPED;
-
-        boolean deleteOnClose = options.contains(StandardOpenOption.DELETE_ON_CLOSE);
-        if (deleteOnClose)
+        if (flags.deleteOnClose)
             dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
 
         // NOFOLLOW_LINKS and NOFOLLOW_REPARSEPOINT mean open reparse point
         boolean okayToFollowLinks = true;
         if (dwCreationDisposition != CREATE_NEW &&
-            (options.contains(LinkOption.NOFOLLOW_LINKS) ||
-             options.contains(NOFOLLOW_REPARSEPOINT) ||
-             deleteOnClose))



More information about the distro-pkg-dev mailing list