private void recursiveDeleteTree(IPath path, IProgressMonitor monitor, MultiStatus status)
     throws IOException, ParseException {
   try {
     changeCurrentDir(path);
     FTPFile[] ftpFiles = listFiles(path, monitor);
     List<String> dirs = new ArrayList<String>();
     for (FTPFile ftpFile : ftpFiles) {
       String name = ftpFile.getName();
       if (".".equals(name) || "..".equals(name)) { // $NON-NLS-1$ //$NON-NLS-2$
         continue;
       }
       if (ftpFile.isDir()) {
         dirs.add(name);
         continue;
       }
       Policy.checkCanceled(monitor);
       monitor.subTask(path.append(name).toPortableString());
       try {
         ftpClient.delete(name);
       } catch (FTPException e) {
         status.add(
             new Status(
                 IStatus.ERROR,
                 FTPPlugin.PLUGIN_ID,
                 StringUtils.format(
                     Messages.FTPConnectionFileManager_deleting_failed,
                     path.append(name).toPortableString()),
                 e));
       }
       monitor.worked(1);
     }
     for (String name : dirs) {
       monitor.subTask(path.append(name).toPortableString());
       recursiveDeleteTree(path.append(name), monitor, status);
       Policy.checkCanceled(monitor);
       changeCurrentDir(path);
       Policy.checkCanceled(monitor);
       ftpClient.rmdir(name);
       monitor.worked(1);
     }
   } catch (IOException e) {
     throw e;
   } catch (Exception e) {
     status.add(
         new Status(
             IStatus.ERROR,
             FTPPlugin.PLUGIN_ID,
             StringUtils.format(
                 Messages.FTPConnectionFileManager_deleting_failed, path.toPortableString()),
             e));
   }
 }
 /* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#deleteDirectory(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
  */
 @Override
 protected void deleteDirectory(IPath path, IProgressMonitor monitor)
     throws CoreException, FileNotFoundException {
   MultiStatus status = new MultiStatus(FTPPlugin.PLUGIN_ID, 0, null, null);
   try {
     IPath dirPath = path.removeLastSegments(1);
     changeCurrentDir(dirPath);
     Policy.checkCanceled(monitor);
     recursiveDeleteTree(path, monitor, status);
     changeCurrentDir(dirPath);
     ftpClient.rmdir(path.lastSegment());
   } catch (FileNotFoundException e) {
     throw e;
   } catch (OperationCanceledException e) {
     throw e;
   } catch (Exception e) {
     if (!status.isOK()) {
       MultiStatus multiStatus =
           new MultiStatus(
               FTPPlugin.PLUGIN_ID,
               0,
               Messages.FTPConnectionFileManager_deleting_directory_failed,
               e);
       multiStatus.addAll(status);
     } else {
       throw new CoreException(
           new Status(
               Status.ERROR,
               FTPPlugin.PLUGIN_ID,
               Messages.FTPConnectionFileManager_deleting_directory_failed,
               e));
     }
   } finally {
     monitor.done();
   }
 }