Esempio n. 1
0
 @CheckForNull
 private File parentDir(Collection<File> dirs, File cursor) {
   for (File dir : dirs) {
     if (PathUtils.canonicalPath(dir).equals(PathUtils.canonicalPath(cursor))) {
       return dir;
     }
   }
   return null;
 }
Esempio n. 2
0
 @CheckForNull
 public String relativePath(File dir, File file) {
   List<String> stack = Lists.newArrayList();
   String dirPath = PathUtils.canonicalPath(dir);
   File cursor = file;
   while (cursor != null) {
     if (dirPath.equals(PathUtils.canonicalPath(cursor))) {
       return Joiner.on("/").join(stack);
     }
     stack.add(0, cursor.getName());
     cursor = cursor.getParentFile();
   }
   return null;
 }
Esempio n. 3
0
 private DefaultInputFile(File file, String path, Map<String, String> attributes) {
   this.absolutePath = PathUtils.canonicalPath(file);
   this.path = FilenameUtils.separatorsToUnix(path);
   this.attributes = attributes;
 }