/**
  * Copies all files matching the <code>filter</code> from <code>fromDir</code> to <code>toDir
  * </code>.
  *
  * @param requestor any object to control who called this method. Note that it is considered to be
  *     an external change if <code>requestor</code> is <code>null</code>. See {@link
  *     VirtualFileEvent#getRequestor}
  * @param fromDir the directory to copy from
  * @param toDir the directory to copy to
  * @param filter {@link VirtualFileFilter}
  * @throws IOException if files failed to be copied
  */
 public static void copyDirectory(
     Object requestor,
     @NotNull VirtualFile fromDir,
     @NotNull VirtualFile toDir,
     @Nullable VirtualFileFilter filter)
     throws IOException {
   VirtualFile[] children = fromDir.getChildren();
   for (VirtualFile child : children) {
     if (filter == null || filter.accept(child)) {
       if (!child.isDirectory()) {
         copyFile(requestor, child, toDir);
       } else {
         VirtualFile newChild = toDir.findChild(child.getName());
         if (newChild == null) {
           newChild = toDir.createChildDirectory(requestor, child.getName());
         }
         copyDirectory(requestor, child, newChild, filter);
       }
     }
   }
 }
Esempio n. 2
0
 /**
  * Copies all files matching the <code>filter</code> from <code>fromDir</code> to <code>toDir
  * </code>. Symlinks end special files are ignored.
  *
  * @param requestor any object to control who called this method. Note that it is considered to be
  *     an external change if <code>requestor</code> is <code>null</code>. See {@link
  *     VirtualFileEvent#getRequestor}
  * @param fromDir the directory to copy from
  * @param toDir the directory to copy to
  * @param filter {@link VirtualFileFilter}
  * @throws IOException if files failed to be copied
  */
 public static void copyDirectory(
     Object requestor,
     @NotNull VirtualFile fromDir,
     @NotNull VirtualFile toDir,
     @Nullable VirtualFileFilter filter)
     throws IOException {
   @SuppressWarnings("UnsafeVfsRecursion")
   VirtualFile[] children = fromDir.getChildren();
   for (VirtualFile child : children) {
     if (!child.isSymLink()
         && !child.isSpecialFile()
         && (filter == null || filter.accept(child))) {
       if (!child.isDirectory()) {
         copyFile(requestor, child, toDir);
       } else {
         VirtualFile newChild = toDir.findChild(child.getName());
         if (newChild == null) {
           newChild = toDir.createChildDirectory(requestor, child.getName());
         }
         copyDirectory(requestor, child, newChild, filter);
       }
     }
   }
 }