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

public final class FS extends Object
Common FileSystem utility methods
  • 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 content to be deleted within the MavenPaths.targetTests() directory.

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

      @Deprecated(forRemoval=true, since="6.0") public static void delete(File path)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version delete(Path)
      Delete a file or a directory.

      Note: safety mechanism only allows content to be deleted within the MavenPaths.targetTests() directory.

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

      @Deprecated(forRemoval=true, since="6.0") public static void deleteDirectory(File dir)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version deleteDirectory(Path)
      Delete a directory and all contents under it.

      Note: safety mechanism only allows content to be deleted within the MavenPaths.targetTests() 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 content to be deleted within the MavenPaths.targetTests() directory.

      Parameters:
      dir - the directory to delete.
    • deleteFile

      @Deprecated(forRemoval=true, since="6.0") public static void deleteFile(File path)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version deleteFile(Path)
      Delete a file.

      Note: safety mechanism only allows content to be deleted within the MavenPaths.targetTests() directory.

      Parameters:
      path - the path to delete.
    • deleteFile

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

      Note: safety mechanism only allows content to be deleted within the MavenPaths.targetTests() 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 MavenPaths.targetTests() directory.

      Parameters:
      path - the path to delete.
    • recursiveDeleteDir

      private static void recursiveDeleteDir(Path path)
    • cleanDirectory

      @Deprecated(forRemoval=true, since="6.0") public static void cleanDirectory(File dir)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version cleanDirectory(Path)
      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 MavenPaths.targetTests() 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 MavenPaths.targetTests() directory.

      Parameters:
      dir - the directory to delete.
    • ensureEmpty

      @Deprecated(forRemoval=true, since="6.0") public static void ensureEmpty(File dir)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version ensureEmpty(Path)
      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.
    • ensureDeleted

      @Deprecated(forRemoval=true) public static void ensureDeleted(File dir)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version ensureDeleted(Path)
      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

      @Deprecated(forRemoval=true, since="6.0") public static void ensureDirExists(File dir)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version ensureDirExists(Path)
      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

      @Deprecated(forRemoval=true, since="6.0") static boolean isTestingDir(File dir)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version isTestingDir(Path)
      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

      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

      @Deprecated(forRemoval=true, since="6.0") public static void touch(File file) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      use Path version touch(Path)
      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.
    • separators

      public static String separators(String path)
      Convert path separators to the System path separators.

      This helps ensure that the paths provided in the unit tests work equally as well on unix / osx / windows.

      Parameters:
      path - the raw path to convert
      Returns:
      the converted path