Ejemplo n.º 1
0
  public static void directoryListJSON(
      IVResource dir, String path, User user, JSONWriter jsonWriter) {
    if (dir.exists()) {
      IVResource[] listFiles = dir.listFiles();
      for (int j = 0; j < listFiles.length; j++) {
        IVResource member = listFiles[j];
        if (Resource.isHidden(member)) continue;

        jsonWriter
            .startObject()
            .addField("name", member.getName())
            .addField("isDir", member.isDirectory())
            .endObject();
      }
      List links = user.getLinks().findLinks(path);
      for (Iterator iterator = links.iterator(); iterator.hasNext(); ) {
        Link link = (Link) iterator.next();
        jsonWriter
            .startObject()
            .addField("name", link.name)
            .addField("isDir", true)
            .addField("link", link.location)
            .endObject();
      }
    }
    /*
    if (path.equals(".") || path.length()==0 || jsonWriter.isEmpty())
    {
    	ServerManager.getServerManger().getLibraryManager().listFiles(path,jsonWriter);

    }
    */

  }
Ejemplo n.º 2
0
  public static void copyDirectory(IVResource source, IVResource destination, boolean recurse) {
    IVResource[] list = source.listFiles();

    for (int i = 0; i < list.length; i++) {
      destination.mkdir();
      IVResource r = destination.create(list[i].getName());
      if (list[i].isDirectory()) {
        r.mkdir();
        if (recurse) {
          VResourceUtils.copyDirectory(list[i], r, recurse);
        }
      } else {
        try {
          if (!r.exists()) {
            r.createNewInstance();
            VResourceUtils.copyFile(list[i], r);
            r.flushWorkingCopy();
          }
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
  }
Ejemplo n.º 3
0
 @Override
 public IVResource[] listFiles() {
   // TODO Auto-generated method stub
   return original.listFiles();
 }