private static @Nullable Collection<IOException> deleteRecursivelySecure(
      SecureDirectoryStream<Path> dir, Path path) {
    """
	Secure recursive delete using {@code SecureDirectoryStream}. Returns a collection of exceptions
	that occurred or null if no exceptions were thrown.
    """
    Collection<IOException> exceptions = null;
    try {
      if (isDirectory(dir, path, NOFOLLOW_LINKS)) {
        try (SecureDirectoryStream<Path> childDir = dir.newDirectoryStream(path, NOFOLLOW_LINKS)) {
          exceptions = deleteDirectoryContentsSecure(childDir);
        }

        // If exceptions is not null, something went wrong trying to delete the contents of the
        // directory, so we shouldn't try to delete the directory as it will probably fail.
        if (exceptions == null) {
          dir.deleteDirectory(path);
        }
      } else {
        dir.deleteFile(path);
      }

      return exceptions;
    } catch (IOException e) {
      return addException(exceptions, e);
    }
  }
private static @Nullable Collection<IOException> deleteRecursivelySecure(
      SecureDirectoryStream<Path> dir, Path path) {
    Collection<IOException> exceptions = null;
    try {
      if (isDirectory(dir, path, NOFOLLOW_LINKS)) {
        try (SecureDirectoryStream<Path> childDir = dir.newDirectoryStream(path, NOFOLLOW_LINKS)) {
          exceptions = deleteDirectoryContentsSecure(childDir);
        }

        // If exceptions is not null, something went wrong trying to delete the contents of the
        // directory, so we shouldn't try to delete the directory as it will probably fail.
        if (exceptions == null) {
          dir.deleteDirectory(path);
        }
      } else {
        dir.deleteFile(path);
      }

      return exceptions;
    } catch (IOException e) {
      return addException(exceptions, e);
    }
  }
private static @ Nullable Collection < IOException > deleteRecursivelySecure ( SecureDirectoryStream < Path > dir , Path path ) { Collection < IOException > exceptions = null ; try { if ( isDirectory ( dir , path , NOFOLLOW_LINKS ) ) { try ( SecureDirectoryStream < Path > childDir = dir . newDirectoryStream ( path , NOFOLLOW_LINKS ) ) { exceptions = deleteDirectoryContentsSecure ( childDir ) ; } // If exceptions is not null, something went wrong trying to delete the contents of the // directory, so we shouldn't try to delete the directory as it will probably fail. if ( exceptions == null ) { dir . deleteDirectory ( path ) ; } } else { dir . deleteFile ( path ) ; } return exceptions ; } catch ( IOException e ) { return addException ( exceptions , e ) ; } }
Secure recursive delete using {@code SecureDirectoryStream}. Returns a collection of exceptions
that occurred or null if no exceptions were thrown.
Secure recursive delete using {