Ejemplo n.º 1
0
 public PersistentDir findOrCreate(File f) throws URISyntaxException {
   if (f.equals(new File(getPath()))) return this;
   if (f.isFile()) {
     throw new IllegalArgumentException("Parameter must be a directory, but was a file!");
   }
   URI rel = super.getPath().relativize(f.toURI());
   String[] segments = rel.toString().split("/");
   URI childURI =
       new URI(getPath() + (getPath().toString().endsWith("/") ? "" : "/") + segments[0]);
   PersistentDir child = (PersistentDir) getChildren().get(childURI);
   if (child == null) {
     child = new PersistentDir();
     child.setPath(childURI);
     child.setLastModified(new File(childURI).lastModified());
     children.put(childURI, child);
   }
   return child.findOrCreate(f);
 }