code: private static RecursiveDeleteResult recursiveDeleteFiles(HdfsEnvironment hdfsEnvironment, HdfsContext context, Path directory, List<String> filePrefixes, boolean deleteEmptyDirectories)
      {
          FileSystem fileSystem;
          try {
              fileSystem = hdfsEnvironment.getFileSystem(context, directory);
  
              if (!fileSystem.exists(directory)) {
                  return new RecursiveDeleteResult(true, ImmutableList.of());
              }
          }
          catch (IOException e) {
              ImmutableList.Builder<String> notDeletedItems = ImmutableList.builder();
              notDeletedItems.add(directory.toString() + "/**");
              return new RecursiveDeleteResult(false, notDeletedItems.build());
          }
  
          return doRecursiveDeleteFiles(fileSystem, directory, filePrefixes, deleteEmptyDirectories);
      }
docs: Attempt to recursively remove eligible files and/or directories in {@code directory}.
  <p>
  When {@code filePrefixes} is not present, all files (but not necessarily directories) will be
  ineligible. If all files shall be deleted, you can use an empty string as {@code filePrefixes}.
  <p>
  When {@code deleteEmptySubDirectory} is true, any empty directory (including directories that
  were originally empty, and directories that become empty after files prefixed with
  {@code filePrefixes} are deleted) will be eligible.
  <p>
  This method will not delete anything that's neither a directory nor a file.
  
  @param filePrefixes prefix of files that should be deleted
  @param deleteEmptyDirectories whether empty directories should be deleted