Esempio n. 1
0
 public PersistentFileObject remove(UnknownFSObject unknownFile) throws URISyntaxException {
   File file = new File(unknownFile.getPath());
   File parent = file.getParentFile();
   PersistentDir parentDir = findOrCreate(parent);
   PersistentFileObject removed = parentDir.getChildren().remove(unknownFile.getPath());
   return removed;
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 public boolean updateTimeStamp(URI uri, long lastModified) throws URISyntaxException {
   URI rel = super.getPath().relativize(uri);
   if (uri.equals(getPath()) || rel.toString().length() == 0) {
     if (lastModified == getLastModified()) {
       if (debug) logger.debug("Directory unchanged: " + getPath());
       return false;
     }
     if (debug) logger.debug("Directory changed: " + getPath());
     setLastModified(lastModified);
     return true;
   }
   String[] segments = rel.toString().split("/");
   URI childURI =
       new URI(getPath() + (getPath().toString().endsWith("/") ? "" : "/") + segments[0]);
   PersistentDir child = (PersistentDir) getChildren().get(childURI);
   if (child == null) {
     if (debug) logger.debug("New directory: " + childURI + " not found in " + getPath());
     return true;
   }
   return child.updateTimeStamp(uri, lastModified);
 }