Class FileHelper

java.lang.Object
io.deephaven.util.files.FileHelper

public class FileHelper extends Object
Utility/helper methods for file operations.
  • Method Details

    • getCanonicalForm

      public static String getCanonicalForm(String path)
      Get the canonical path for the given path string, converting IOExceptions to UncheckIOException.
      Parameters:
      path - The file (as String) for which to get the canonical form.
      Returns:
      the canonical file string.
    • deleteRecursivelyOnNFS

      public static boolean deleteRecursivelyOnNFS(File file, String excludePattern)
      Augment FileUtils.deleteRecursivelyOnNFS(File) with an exclude pattern. Files matching the pattern will not be removed, nor will containing directories.
      Parameters:
      file - the file or folder to delete.
      excludePattern - don't delete files or folders matching this pattern.
      Returns:
      true if any files were excluded (so caller will know if a directory is empty)
      Throws:
      FileHelper.FileDeletionException - on any errors moving/renaming/deleting files
    • deleteRecursivelyOnNFS

      public static boolean deleteRecursivelyOnNFS(File file, Pattern excludePattern)
      Augment FileUtils.deleteRecursivelyOnNFS(File) with an exclude pattern. Files matching the pattern will not be removed, nor will containing directories.
      Parameters:
      file - the file or folder to delete.
      excludePattern - don't delete files or folders matching this pattern.
      Returns:
      true if any files were excluded (so caller will know if a directory is empty)
      Throws:
      FileHelper.FileDeletionException - on any errors moving/renaming/deleting files
    • deleteRecursivelyOnNFS

      public static boolean deleteRecursivelyOnNFS(File trashFile, File fileToBeDeleted, @Nullable @Nullable Pattern excludePattern)
      Augment FileUtils.deleteRecursivelyOnNFS(File, File) with an exclude pattern. Files matching the pattern will not be removed, nor will containing directories.

      This is an implementation method for deleteRecursivelyOnNFS(File, String)

      Parameters:
      trashFile - Filename to move regular files to before deletion. .nfs files may be created in its parent directory.
      fileToBeDeleted - File or directory at which to begin recursive deletion.
      excludePattern - don't delete files or folders matching this pattern.
      Returns:
      true if any files were excluded (so caller will know if a directory is empty)
      Throws:
      FileHelper.FileDeletionException - on any errors moving/renaming/deleting files