mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-19 04:13:07 +00:00
7003006: add option to list directory in deterministic order
Reviewed-by: mcimadamore
This commit is contained in:
parent
cba5c7df9f
commit
68ea64e30f
@ -25,6 +25,7 @@
|
||||
|
||||
package com.sun.tools.javac.file;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -110,6 +111,20 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
protected boolean mmappedIO;
|
||||
protected boolean ignoreSymbolFile;
|
||||
|
||||
protected enum SortFiles implements Comparator<File> {
|
||||
FORWARD {
|
||||
public int compare(File f1, File f2) {
|
||||
return f1.getName().compareTo(f2.getName());
|
||||
}
|
||||
},
|
||||
REVERSE {
|
||||
public int compare(File f1, File f2) {
|
||||
return -f1.getName().compareTo(f2.getName());
|
||||
}
|
||||
};
|
||||
};
|
||||
protected SortFiles sortFiles;
|
||||
|
||||
/**
|
||||
* Register a Context.Factory to create a JavacFileManager.
|
||||
*/
|
||||
@ -152,6 +167,11 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
|
||||
mmappedIO = options.isSet("mmappedIO");
|
||||
ignoreSymbolFile = options.isSet("ignore.symbol.file");
|
||||
|
||||
String sf = options.get("sortFiles");
|
||||
if (sf != null) {
|
||||
sortFiles = (sf.equals("reverse") ? SortFiles.REVERSE : SortFiles.FORWARD);
|
||||
}
|
||||
}
|
||||
|
||||
public JavaFileObject getFileForInput(String name) {
|
||||
@ -293,6 +313,9 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
if (files == null)
|
||||
return;
|
||||
|
||||
if (sortFiles != null)
|
||||
Arrays.sort(files, sortFiles);
|
||||
|
||||
for (File f: files) {
|
||||
String fname = f.getName();
|
||||
if (f.isDirectory()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user