< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java

Print this page




 107 
 108     @Override
 109     public Path getPath() {
 110         return dirPath;
 111     }
 112 
 113     @Override
 114     public Stream<Entry> entries() {
 115         try {
 116             return Files.walk(dirPath).map(this::toEntry).filter(n -> n != null);
 117         } catch (IOException ex) {
 118             throw new RuntimeException(ex);
 119         }
 120     }
 121 
 122     private Archive.Entry toEntry(Path p) {
 123         if (Files.isDirectory(p)) {
 124             return null;
 125         }
 126         String name = getPathName(p).substring(chop);
 127         if (name.startsWith("_")) {
 128             return null;
 129         }
 130         log.accept(moduleName + "/" + name);
 131         if (name.equals(MODULE_INFO)) {
 132             name = moduleName + "/" + MODULE_INFO;
 133         }
 134         return new FileEntry(p, name);
 135     }
 136 
 137     @Override
 138     public void close() throws IOException {
 139         IOException e = null;
 140         for (InputStream stream : open) {
 141             try {
 142                 stream.close();
 143             } catch (IOException ex) {
 144                 if (e == null) {
 145                     e = ex;
 146                 } else {
 147                     e.addSuppressed(ex);
 148                 }
 149             }
 150         }
 151         if (e != null) {
 152             throw e;
 153         }


 107 
 108     @Override
 109     public Path getPath() {
 110         return dirPath;
 111     }
 112 
 113     @Override
 114     public Stream<Entry> entries() {
 115         try {
 116             return Files.walk(dirPath).map(this::toEntry).filter(n -> n != null);
 117         } catch (IOException ex) {
 118             throw new RuntimeException(ex);
 119         }
 120     }
 121 
 122     private Archive.Entry toEntry(Path p) {
 123         if (Files.isDirectory(p)) {
 124             return null;
 125         }
 126         String name = getPathName(p).substring(chop);



 127         log.accept(moduleName + "/" + name);



 128         return new FileEntry(p, name);
 129     }
 130 
 131     @Override
 132     public void close() throws IOException {
 133         IOException e = null;
 134         for (InputStream stream : open) {
 135             try {
 136                 stream.close();
 137             } catch (IOException ex) {
 138                 if (e == null) {
 139                     e = ex;
 140                 } else {
 141                     e.addSuppressed(ex);
 142                 }
 143             }
 144         }
 145         if (e != null) {
 146             throw e;
 147         }
< prev index next >