23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.file; |
26 package com.sun.tools.javac.file; |
27 |
27 |
|
28 import java.io.ByteArrayInputStream; |
28 import java.io.IOException; |
29 import java.io.IOException; |
29 import java.util.Set; |
|
30 import javax.tools.JavaFileObject; |
|
31 |
|
32 import java.io.ByteArrayInputStream; |
|
33 import java.io.File; |
|
34 import java.io.InputStream; |
30 import java.io.InputStream; |
35 import java.io.OutputStream; |
31 import java.io.OutputStream; |
36 import java.io.Writer; |
32 import java.io.Writer; |
37 import java.net.URI; |
33 import java.net.URI; |
38 import java.nio.ByteBuffer; |
34 import java.nio.ByteBuffer; |
39 import java.nio.CharBuffer; |
35 import java.nio.CharBuffer; |
40 import java.nio.charset.CharsetDecoder; |
36 import java.nio.charset.CharsetDecoder; |
|
37 import java.nio.file.Path; |
|
38 import java.util.Set; |
|
39 |
|
40 import javax.tools.JavaFileObject; |
41 |
41 |
42 import com.sun.tools.javac.file.JavacFileManager.Archive; |
42 import com.sun.tools.javac.file.JavacFileManager.Archive; |
43 import com.sun.tools.javac.file.RelativePath.RelativeDirectory; |
43 import com.sun.tools.javac.file.RelativePath.RelativeDirectory; |
44 import com.sun.tools.javac.file.RelativePath.RelativeFile; |
44 import com.sun.tools.javac.file.RelativePath.RelativeFile; |
45 import com.sun.tools.javac.util.Assert; |
45 import com.sun.tools.javac.util.Assert; |
54 * deletion without notice.</b> |
54 * deletion without notice.</b> |
55 */ |
55 */ |
56 public class ZipFileIndexArchive implements Archive { |
56 public class ZipFileIndexArchive implements Archive { |
57 |
57 |
58 private final ZipFileIndex zfIndex; |
58 private final ZipFileIndex zfIndex; |
59 private JavacFileManager fileManager; |
59 private final JavacFileManager fileManager; |
60 |
60 |
61 public ZipFileIndexArchive(JavacFileManager fileManager, ZipFileIndex zdir) throws IOException { |
61 public ZipFileIndexArchive(JavacFileManager fileManager, ZipFileIndex zdir) throws IOException { |
62 super(); |
62 super(); |
63 this.fileManager = fileManager; |
63 this.fileManager = fileManager; |
64 this.zfIndex = zdir; |
64 this.zfIndex = zdir; |
109 */ |
109 */ |
110 ZipFileIndex.Entry entry; |
110 ZipFileIndex.Entry entry; |
111 |
111 |
112 /** The name of the zip file where this entry resides. |
112 /** The name of the zip file where this entry resides. |
113 */ |
113 */ |
114 File zipName; |
114 Path zipName; |
115 |
115 |
116 |
116 |
117 ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, File zipFileName) { |
117 ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, Path zipFileName) { |
118 super(fileManager); |
118 super(fileManager); |
119 this.name = entry.getFileName(); |
119 this.name = entry.getFileName(); |
120 this.zfIndex = zfIndex; |
120 this.zfIndex = zfIndex; |
121 this.entry = entry; |
121 this.entry = entry; |
122 this.zipName = zipFileName; |
122 this.zipName = zipFileName; |
132 return zipName + "(" + getPrefixedEntryName() + ")"; |
132 return zipName + "(" + getPrefixedEntryName() + ")"; |
133 } |
133 } |
134 |
134 |
135 @Override |
135 @Override |
136 public String getShortName() { |
136 public String getShortName() { |
137 return zipName.getName() + "(" + entry.getName() + ")"; |
137 return zipName.getFileName() + "(" + entry.getName() + ")"; |
138 } |
138 } |
139 |
139 |
140 @Override @DefinedBy(Api.COMPILER) |
140 @Override @DefinedBy(Api.COMPILER) |
141 public JavaFileObject.Kind getKind() { |
141 public JavaFileObject.Kind getKind() { |
142 return getKind(entry.getName()); |
142 return getKind(entry.getName()); |
192 protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) { |
192 protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) { |
193 return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors); |
193 return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors); |
194 } |
194 } |
195 |
195 |
196 @Override |
196 @Override |
197 protected String inferBinaryName(Iterable<? extends File> path) { |
197 protected String inferBinaryName(Iterable<? extends Path> path) { |
198 String entryName = entry.getName(); |
198 String entryName = entry.getName(); |
199 if (zfIndex.symbolFilePrefix != null) { |
199 if (zfIndex.symbolFilePrefix != null) { |
200 String prefix = zfIndex.symbolFilePrefix.path; |
200 String prefix = zfIndex.symbolFilePrefix.path; |
201 if (entryName.startsWith(prefix)) |
201 if (entryName.startsWith(prefix)) |
202 entryName = entryName.substring(prefix.length()); |
202 entryName = entryName.substring(prefix.length()); |