java.lang.Object
org.eclipse.jetty.toolchain.test.FS

public final class FS extends Object
Common FileSystem utility methods
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    FS()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Delete the contents of a directory and all contents under it, leaving the directory itself still in existance.
    static void
    Delete the contents of a directory and all contents under it, leaving the directory itself still in existance.
    static void
    delete(File path)
    Delete a file or a directory.
    static void
    delete(Path path)
    Delete a file or a directory.
    static void
    Delete a directory.
    static void
    Delete a directory and all contents under it.
    static void
    Delete a directory and all contents under it.
    static void
    Delete a file.
    static void
    Delete a file.
    static void
    Ensure the provided directory does not exist, delete it if present
    static void
    Ensure the provided directory does not exist, delete it if present
    static void
    Ensure that directory exists, create it if not present.
    static void
    Ensure that directory exists, create it if not present.
    static void
    Ensure the provided directory exists, and contains no content (empty)
    static void
    Ensure the provided directory exists, and contains no content (empty)
    static void
    ensureEmpty(TestingDir testingdir)
    Ensure the provided directory exists, and contains no content (empty)
    protected static boolean
    Internal class used to detect if the directory is a valid testing directory.
    protected static boolean
    Internal class used to detect if the directory is a valid testing directory.
    private static void
     
    static void
    touch(File file)
    Create an empty file at the location.
    static void
    touch(Path file)
    Create an empty file at the location.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FS

      private FS()
  • Method Details

    • delete

      public static void delete(Path path)
      Delete a file or a directory.

      Note: safety mechanism only allows delete within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      path - the file or directory to delete.
    • delete

      public static void delete(File path)
      Delete a file or a directory.

      Note: safety mechanism only allows delete within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      path - the file or directory to delete.
    • deleteDirectory

      public static void deleteDirectory(File dir)
      Delete a directory and all contents under it.

      Note: safety mechanism only allows delete directory within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      dir - the directory to delete.
    • deleteDirectory

      public static void deleteDirectory(Path dir)
      Delete a directory and all contents under it.

      Note: safety mechanism only allows delete directory within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      dir - the directory to delete.
    • deleteFile

      public static void deleteFile(File path)
      Delete a file.

      Note: safety mechanism only allows delete file within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      path - the path to delete.
    • deleteFile

      public static void deleteFile(Path path)
      Delete a file.

      Note: safety mechanism only allows delete file within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      path - the path to delete.
    • deleteDir

      public static void deleteDir(Path path)
      Delete a directory. (only if it is empty)

      Note: safety mechanism only allows delete file within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      path - the path to delete.
    • recursiveDeleteDir

      private static void recursiveDeleteDir(Path path)
    • cleanDirectory

      public static void cleanDirectory(File dir)
      Delete the contents of a directory and all contents under it, leaving the directory itself still in existance.

      Note: safety mechanism only allows clean directory within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      dir - the directory to delete.
    • cleanDirectory

      public static void cleanDirectory(Path dir)
      Delete the contents of a directory and all contents under it, leaving the directory itself still in existance.

      Note: safety mechanism only allows clean directory within the MavenTestingUtils.getTargetTestingDir() directory.

      Parameters:
      dir - the directory to delete.
    • ensureEmpty

      public static void ensureEmpty(File dir)
      Ensure the provided directory exists, and contains no content (empty)
      Parameters:
      dir - the dir to check.
    • ensureEmpty

      public static void ensureEmpty(Path dir)
      Ensure the provided directory exists, and contains no content (empty)
      Parameters:
      dir - the dir to check.
    • ensureEmpty

      public static void ensureEmpty(TestingDir testingdir)
      Ensure the provided directory exists, and contains no content (empty)
      Parameters:
      testingdir - the dir to check.
    • ensureDeleted

      public static void ensureDeleted(File dir)
      Ensure the provided directory does not exist, delete it if present
      Parameters:
      dir - the dir to check
    • ensureDeleted

      public static void ensureDeleted(Path dir)
      Ensure the provided directory does not exist, delete it if present
      Parameters:
      dir - the dir to check
    • ensureDirExists

      public static void ensureDirExists(File dir)
      Ensure that directory exists, create it if not present. Leave it alone if already there.
      Parameters:
      dir - the dir to check.
    • ensureDirExists

      public static void ensureDirExists(Path dir)
      Ensure that directory exists, create it if not present. Leave it alone if already there.
      Parameters:
      dir - the dir to check.
    • isTestingDir

      protected static boolean isTestingDir(File dir)
      Internal class used to detect if the directory is a valid testing directory.

      Used as part of the validation on what directories are safe to delete from.

      Parameters:
      dir - the dir to check
      Returns:
      true if provided directory is a testing directory
    • isTestingDir

      protected static boolean isTestingDir(Path dir)
      Internal class used to detect if the directory is a valid testing directory.

      Used as part of the validation on what directories are safe to delete from.

      Parameters:
      dir - the dir to check
      Returns:
      true if provided directory is a testing directory
    • touch

      public static void touch(File file) throws IOException
      Create an empty file at the location. If the file exists, just update the last modified timestamp.
      Parameters:
      file - the file to create or update the timestamp of.
      Throws:
      IOException - if unable to create the new file.
    • touch

      public static void touch(Path file) throws IOException
      Create an empty file at the location. If the file exists, just update the last modified timestamp.
      Parameters:
      file - the file to create or update the timestamp of.
      Throws:
      IOException - if unable to create the new file.