< prev index next >

src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java

Print this page




 135      * other non-POSIX attributes. This method is invoked by the
 136      * copy or move operation to preserve these attributes. It should copy
 137      * extended attributes, ACLs, or other attributes.
 138      *
 139      * @param   sfd
 140      *          Open file descriptor to source file
 141      * @param   tfd
 142      *          Open file descriptor to target file
 143      */
 144     void copyNonPosixAttributes(int sfd, int tfd) {
 145         // no-op by default
 146     }
 147 
 148     /**
 149      * Unix systems only have a single root directory (/)
 150      */
 151     @Override
 152     public final Iterable<Path> getRootDirectories() {
 153         final List<Path> allowedList =
 154            Collections.unmodifiableList(Arrays.asList((Path)rootDirectory));
 155         return new Iterable<Path>() {
 156             public Iterator<Path> iterator() {
 157                 try {
 158                     SecurityManager sm = System.getSecurityManager();
 159                     if (sm != null)
 160                         sm.checkRead(rootDirectory.toString());
 161                     return allowedList.iterator();
 162                 } catch (SecurityException x) {
 163                     List<Path> disallowed = Collections.emptyList();
 164                     return disallowed.iterator();
 165                 }
 166             }
 167         };
 168     }
 169 
 170     /**
 171      * Returns object to iterate over entries in mounttab or equivalent
 172      */
 173     abstract Iterable<UnixMountEntry> getMountEntries();
 174 
 175     /**


 237                 return result;
 238             }
 239         }
 240 
 241         @Override
 242         public void remove() {
 243             throw new UnsupportedOperationException();
 244         }
 245     }
 246 
 247     @Override
 248     public final Iterable<FileStore> getFileStores() {
 249         SecurityManager sm = System.getSecurityManager();
 250         if (sm != null) {
 251             try {
 252                 sm.checkPermission(new RuntimePermission("getFileStoreAttributes"));
 253             } catch (SecurityException se) {
 254                 return Collections.emptyList();
 255             }
 256         }
 257         return new Iterable<FileStore>() {
 258             public Iterator<FileStore> iterator() {
 259                 return new FileStoreIterator();
 260             }
 261         };
 262     }
 263 
 264     @Override
 265     public final Path getPath(String first, String... more) {
 266         String path;
 267         if (more.length == 0) {
 268             path = first;
 269         } else {
 270             StringBuilder sb = new StringBuilder();
 271             sb.append(first);
 272             for (String segment: more) {
 273                 if (segment.length() > 0) {
 274                     if (sb.length() > 0)
 275                         sb.append('/');
 276                     sb.append(segment);
 277                 }




 135      * other non-POSIX attributes. This method is invoked by the
 136      * copy or move operation to preserve these attributes. It should copy
 137      * extended attributes, ACLs, or other attributes.
 138      *
 139      * @param   sfd
 140      *          Open file descriptor to source file
 141      * @param   tfd
 142      *          Open file descriptor to target file
 143      */
 144     void copyNonPosixAttributes(int sfd, int tfd) {
 145         // no-op by default
 146     }
 147 
 148     /**
 149      * Unix systems only have a single root directory (/)
 150      */
 151     @Override
 152     public final Iterable<Path> getRootDirectories() {
 153         final List<Path> allowedList =
 154            Collections.unmodifiableList(Arrays.asList((Path)rootDirectory));
 155         return new Iterable<>() {
 156             public Iterator<Path> iterator() {
 157                 try {
 158                     SecurityManager sm = System.getSecurityManager();
 159                     if (sm != null)
 160                         sm.checkRead(rootDirectory.toString());
 161                     return allowedList.iterator();
 162                 } catch (SecurityException x) {
 163                     List<Path> disallowed = Collections.emptyList();
 164                     return disallowed.iterator();
 165                 }
 166             }
 167         };
 168     }
 169 
 170     /**
 171      * Returns object to iterate over entries in mounttab or equivalent
 172      */
 173     abstract Iterable<UnixMountEntry> getMountEntries();
 174 
 175     /**


 237                 return result;
 238             }
 239         }
 240 
 241         @Override
 242         public void remove() {
 243             throw new UnsupportedOperationException();
 244         }
 245     }
 246 
 247     @Override
 248     public final Iterable<FileStore> getFileStores() {
 249         SecurityManager sm = System.getSecurityManager();
 250         if (sm != null) {
 251             try {
 252                 sm.checkPermission(new RuntimePermission("getFileStoreAttributes"));
 253             } catch (SecurityException se) {
 254                 return Collections.emptyList();
 255             }
 256         }
 257         return new Iterable<>() {
 258             public Iterator<FileStore> iterator() {
 259                 return new FileStoreIterator();
 260             }
 261         };
 262     }
 263 
 264     @Override
 265     public final Path getPath(String first, String... more) {
 266         String path;
 267         if (more.length == 0) {
 268             path = first;
 269         } else {
 270             StringBuilder sb = new StringBuilder();
 271             sb.append(first);
 272             for (String segment: more) {
 273                 if (segment.length() > 0) {
 274                     if (sb.length() > 0)
 275                         sb.append('/');
 276                     sb.append(segment);
 277                 }


< prev index next >