Пример #1
0
 @Override
 @Port(name = "files", method = "getTree")
 public AbstractItem getTree(AbstractItem absRoot) {
   String nameDirectory = absRoot.getName();
   File file = new File(nameDirectory);
   FolderItem root = new FolderItem();
   root.setName(absRoot.getName());
   root.setPath("/");
   process(file, root);
   sortList(root.getChilds());
   return root;
 }
Пример #2
0
 public void process(File file, FolderItem item) {
   if (!file.getName().contains(".git") && !file.getName().endsWith("~")) {
     if (file.isFile()) {
       FileItem itemToAdd = new FileItem();
       itemToAdd.setName(file.getName());
       itemToAdd.setParent(item);
       itemToAdd.setPath(getRelativePath(file.getPath()));
       item.add(itemToAdd);
     } else if (file.isDirectory()) {
       FolderItem folder = new FolderItem();
       folder.setName(file.getName());
       folder.setParent(item);
       folder.setPath(getRelativePath(file.getPath() + "/"));
       item.add(folder);
       File[] listOfFiles = file.listFiles();
       if (listOfFiles != null) {
         for (File listOfFile : listOfFiles) process(listOfFile, folder);
       }
     }
   }
 }