langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java
changeset 27858 443efec4bf09
parent 27579 d1a63c99cdd5
parent 27852 2e6ad0e4fe20
child 34560 b6a567b677f7
equal deleted inserted replaced
27581:9fffb959eb41 27858:443efec4bf09
    55 
    55 
    56     public abstract RelativeDirectory dirname();
    56     public abstract RelativeDirectory dirname();
    57 
    57 
    58     public abstract String basename();
    58     public abstract String basename();
    59 
    59 
    60     public File getFile(File directory) {
       
    61         if (path.length() == 0)
       
    62             return directory;
       
    63         return new File(directory, path.replace('/', File.separatorChar));
       
    64     }
       
    65 
       
    66     public Path getFile(Path directory) throws /*unchecked*/ InvalidPathException {
    60     public Path getFile(Path directory) throws /*unchecked*/ InvalidPathException {
    67         if (directory == null) {
    61         if (directory == null) {
    68             String sep = FileSystems.getDefault().getSeparator();
    62             String sep = FileSystems.getDefault().getSeparator();
    69             return Paths.get(path.replace("/", sep));
    63             return Paths.get(path.replace("/", sep));
    70         } else {
    64         } else {
    71             String sep = directory.getFileSystem().getSeparator();
    65             String sep = directory.getFileSystem().getSeparator();
    72             return directory.resolve(path.replace("/", sep));
    66             return directory.resolve(path.replace("/", sep));
    73         }
    67         }
    74     }
    68     }
    75 
    69 
       
    70     @Override
    76     public int compareTo(RelativePath other) {
    71     public int compareTo(RelativePath other) {
    77         return path.compareTo(other.path);
    72         return path.compareTo(other.path);
    78     }
    73     }
    79 
    74 
    80     @Override
    75     @Override