@Override public SetLocation file(String file) { this.file = (file != null) ? IO.normalizePath(file) : null; return this; }
@Override public SetLocation file(String file) { this.file = (file != null) ? IO.normalizePath(file) : null; return this; }
public static String absolutePath(Path path) { return normalizePath(path.toAbsolutePath()); }
public static String absolutePath(File file) { return normalizePath(file.getAbsolutePath()); }
public static String normalizePath(Path path) { return normalizePath(path.toString()); }
public static String absolutePath(File file) { return normalizePath(file.getAbsolutePath()); }
public static String normalizePath(Path path) { return normalizePath(path.toString()); }
public static String normalizePath(Path path) { return normalizePath(path.toString()); }
public static String absolutePath(File file) { return normalizePath(file.getAbsolutePath()); }
public static String absolutePath(Path path) { return normalizePath(path.toAbsolutePath()); }
public static String normalizePath(File file) { return normalizePath(file.getPath()); }
public static String normalizePath(Path path) { return normalizePath(path.toString()); }
public static String absolutePath(Path path) { return normalizePath(path.toAbsolutePath()); }
public static String normalizePath(File file) { return normalizePath(file.getPath()); }
public static String normalizePath(Path path) { return normalizePath(path.toString()); }
/** * Make the file short if it is inside our base directory, otherwise long. * * @param file */ public String normalize(String file) { file = IO.normalizePath(file); String path = IO.absolutePath(base); int len = path.length(); if (file.startsWith(path) && file.charAt(len) == '/') { return file.substring(len + 1); } return file; }
/** * Make the file short if it is inside our base directory, otherwise long. * * @param file */ public String normalize(String file) { file = IO.normalizePath(file); String path = IO.absolutePath(base); int len = path.length(); if (file.startsWith(path) && file.charAt(len) == '/') { return file.substring(len + 1); } return file; }
private URI relativize(File file) { if (base == null) { return file.toURI(); } Path filePath = file.toPath() .toAbsolutePath(); Path relativePath = base.relativize(filePath); // Note that relativePath.toURI() gives the wrong answer for us! // We have to do some Windows related mashing here too :( URI relativeURI = URI.create(IO.normalizePath(relativePath)); reporter.trace("Resolving %s relative to %s; Relative Path: %s, URI: %s", filePath, base, relativePath, relativeURI); return relativeURI; }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { String relativePath = IO.normalizePath(baseDir.relativize(file)); putResource(relativePath, new FileResource(file, attrs), true); return FileVisitResult.CONTINUE; } });
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { String relativePath = IO.normalizePath(baseDir.relativize(file)); putResource(relativePath, new FileResource(file, attrs), true); return FileVisitResult.CONTINUE; } });