Beispiel #1
0
 private static File join(File file, Object[] path) {
   File current = file.getAbsoluteFile();
   for (Object p : path) {
     current = new File(current, p.toString());
   }
   try {
     return current.getCanonicalFile();
   } catch (IOException e) {
     throw new RuntimeException(String.format("Could not canonicalise '%s'.", current), e);
   }
 }
Beispiel #2
0
 public void moveToDirectory(File target) {
   if (target.exists() && !target.isDirectory()) {
     throw new RuntimeException(String.format("Target '%s' is not a directory", target));
   }
   try {
     FileUtils.moveFileToDirectory(this, target, true);
   } catch (IOException e) {
     throw new RuntimeException(
         String.format("Could not move test file '%s' to directory '%s'", this, target), e);
   }
 }
Beispiel #3
0
 private void visit(Set<String> names, String prefix, File file) {
   for (File child : file.listFiles()) {
     if (child.isFile()) {
       names.add(prefix + child.getName());
     } else if (child.isDirectory()) {
       visit(names, prefix + child.getName() + "/", child);
     }
   }
 }
Beispiel #4
0
 public boolean isSelfOrDescendent(File file) {
   if (file.getAbsolutePath().equals(getAbsolutePath())) {
     return true;
   }
   return file.getAbsolutePath().startsWith(getAbsolutePath() + File.separatorChar);
 }
Beispiel #5
0
 public void createLink(File target) {
   createLink(target.getAbsolutePath());
 }