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.util.Comparator; |
28 import java.io.ByteArrayOutputStream; |
29 import java.io.ByteArrayOutputStream; |
29 import java.io.File; |
30 import java.io.File; |
30 import java.io.FileNotFoundException; |
31 import java.io.FileNotFoundException; |
31 import java.io.IOException; |
32 import java.io.IOException; |
32 import java.io.OutputStreamWriter; |
33 import java.io.OutputStreamWriter; |
108 private File sourceOutDir = uninited; |
109 private File sourceOutDir = uninited; |
109 |
110 |
110 protected boolean mmappedIO; |
111 protected boolean mmappedIO; |
111 protected boolean ignoreSymbolFile; |
112 protected boolean ignoreSymbolFile; |
112 |
113 |
|
114 protected enum SortFiles implements Comparator<File> { |
|
115 FORWARD { |
|
116 public int compare(File f1, File f2) { |
|
117 return f1.getName().compareTo(f2.getName()); |
|
118 } |
|
119 }, |
|
120 REVERSE { |
|
121 public int compare(File f1, File f2) { |
|
122 return -f1.getName().compareTo(f2.getName()); |
|
123 } |
|
124 }; |
|
125 }; |
|
126 protected SortFiles sortFiles; |
|
127 |
113 /** |
128 /** |
114 * Register a Context.Factory to create a JavacFileManager. |
129 * Register a Context.Factory to create a JavacFileManager. |
115 */ |
130 */ |
116 public static void preRegister(final Context context) { |
131 public static void preRegister(final Context context) { |
117 context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() { |
132 context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() { |
150 |
165 |
151 useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null; |
166 useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null; |
152 |
167 |
153 mmappedIO = options.isSet("mmappedIO"); |
168 mmappedIO = options.isSet("mmappedIO"); |
154 ignoreSymbolFile = options.isSet("ignore.symbol.file"); |
169 ignoreSymbolFile = options.isSet("ignore.symbol.file"); |
|
170 |
|
171 String sf = options.get("sortFiles"); |
|
172 if (sf != null) { |
|
173 sortFiles = (sf.equals("reverse") ? SortFiles.REVERSE : SortFiles.FORWARD); |
|
174 } |
155 } |
175 } |
156 |
176 |
157 public JavaFileObject getFileForInput(String name) { |
177 public JavaFileObject getFileForInput(String name) { |
158 return getRegularFile(new File(name)); |
178 return getRegularFile(new File(name)); |
159 } |
179 } |
290 return; |
310 return; |
291 |
311 |
292 File[] files = d.listFiles(); |
312 File[] files = d.listFiles(); |
293 if (files == null) |
313 if (files == null) |
294 return; |
314 return; |
|
315 |
|
316 if (sortFiles != null) |
|
317 Arrays.sort(files, sortFiles); |
295 |
318 |
296 for (File f: files) { |
319 for (File f: files) { |
297 String fname = f.getName(); |
320 String fname = f.getName(); |
298 if (f.isDirectory()) { |
321 if (f.isDirectory()) { |
299 if (recurse && SourceVersion.isIdentifier(fname)) { |
322 if (recurse && SourceVersion.isIdentifier(fname)) { |