src/solaris/classes/sun/nio/fs/UnixChannelFactory.java

Print this page
rev 6099 : [mq]: io-trace


  83                         default: throw new UnsupportedOperationException();
  84                     }
  85                     continue;
  86                 }
  87                 if (option == LinkOption.NOFOLLOW_LINKS && supportsNoFollowLinks()) {
  88                     flags.noFollowLinks = true;
  89                     continue;
  90                 }
  91                 if (option == null)
  92                     throw new NullPointerException();
  93                throw new UnsupportedOperationException(option + " not supported");
  94             }
  95             return flags;
  96         }
  97     }
  98 
  99 
 100     /**
 101      * Constructs a file channel from an existing (open) file descriptor
 102      */
 103     static FileChannel newFileChannel(int fd, boolean reading, boolean writing) {
 104         FileDescriptor fdObj = new FileDescriptor();
 105         fdAccess.set(fdObj, fd);
 106         return FileChannelImpl.open(fdObj, reading, writing, null);
 107     }
 108 
 109     /**
 110      * Constructs a file channel by opening a file using a dfd/path pair
 111      */
 112     static FileChannel newFileChannel(int dfd,
 113                                       UnixPath path,
 114                                       String pathForPermissionCheck,
 115                                       Set<? extends OpenOption> options,
 116                                       int mode)
 117         throws UnixException
 118     {
 119         Flags flags = Flags.toFlags(options);
 120 
 121         // default is reading; append => writing
 122         if (!flags.read && !flags.write) {
 123             if (flags.append) {
 124                 flags.write = true;
 125             } else {
 126                 flags.read = true;
 127             }
 128         }
 129 
 130         // validation
 131         if (flags.read && flags.append)
 132             throw new IllegalArgumentException("READ + APPEND not allowed");
 133         if (flags.append && flags.truncateExisting)
 134             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 135 
 136         FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
 137         return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);

 138     }
 139 
 140     /**
 141      * Constructs a file channel by opening the given file.
 142      */
 143     static FileChannel newFileChannel(UnixPath path,
 144                                       Set<? extends OpenOption> options,
 145                                       int mode)
 146         throws UnixException
 147     {
 148         return newFileChannel(-1, path, null, options, mode);
 149     }
 150 
 151     /**
 152      * Constructs an asynchronous file channel by opening the given file.
 153      */
 154     static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
 155                                                               Set<? extends OpenOption> options,
 156                                                               int mode,
 157                                                               ThreadPool pool)




  83                         default: throw new UnsupportedOperationException();
  84                     }
  85                     continue;
  86                 }
  87                 if (option == LinkOption.NOFOLLOW_LINKS && supportsNoFollowLinks()) {
  88                     flags.noFollowLinks = true;
  89                     continue;
  90                 }
  91                 if (option == null)
  92                     throw new NullPointerException();
  93                throw new UnsupportedOperationException(option + " not supported");
  94             }
  95             return flags;
  96         }
  97     }
  98 
  99 
 100     /**
 101      * Constructs a file channel from an existing (open) file descriptor
 102      */
 103     static FileChannel newFileChannel(int fd, String path, boolean reading, boolean writing) {
 104         FileDescriptor fdObj = new FileDescriptor();
 105         fdAccess.set(fdObj, fd);
 106         return FileChannelImpl.open(fdObj, path, reading, writing, null);
 107     }
 108 
 109     /**
 110      * Constructs a file channel by opening a file using a dfd/path pair
 111      */
 112     static FileChannel newFileChannel(int dfd,
 113                                       UnixPath path,
 114                                       String pathForPermissionCheck,
 115                                       Set<? extends OpenOption> options,
 116                                       int mode)
 117         throws UnixException
 118     {
 119         Flags flags = Flags.toFlags(options);
 120 
 121         // default is reading; append => writing
 122         if (!flags.read && !flags.write) {
 123             if (flags.append) {
 124                 flags.write = true;
 125             } else {
 126                 flags.read = true;
 127             }
 128         }
 129 
 130         // validation
 131         if (flags.read && flags.append)
 132             throw new IllegalArgumentException("READ + APPEND not allowed");
 133         if (flags.append && flags.truncateExisting)
 134             throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
 135 
 136         FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
 137         return FileChannelImpl.open(fdObj, path.toString(),
 138             flags.read, flags.write, flags.append, null);
 139     }
 140 
 141     /**
 142      * Constructs a file channel by opening the given file.
 143      */
 144     static FileChannel newFileChannel(UnixPath path,
 145                                       Set<? extends OpenOption> options,
 146                                       int mode)
 147         throws UnixException
 148     {
 149         return newFileChannel(-1, path, null, options, mode);
 150     }
 151 
 152     /**
 153      * Constructs an asynchronous file channel by opening the given file.
 154      */
 155     static AsynchronousFileChannel newAsynchronousFileChannel(UnixPath path,
 156                                                               Set<? extends OpenOption> options,
 157                                                               int mode,
 158                                                               ThreadPool pool)