Class FS
- java.lang.Object
-
- org.eclipse.jetty.toolchain.test.FS
-
public final class FS extends java.lang.ObjectCommon FileSystem utility methods
-
-
Constructor Summary
Constructors Modifier Constructor Description privateFS()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanDirectory(java.io.File dir)Delete the contents of a directory and all contents under it, leaving the directory itself still in existance.static voidcleanDirectory(java.nio.file.Path dir)Delete the contents of a directory and all contents under it, leaving the directory itself still in existance.static voiddelete(java.io.File path)Delete a file or a directory.static voiddelete(java.nio.file.Path path)Delete a file or a directory.static voiddeleteDir(java.nio.file.Path path)Delete a directory.static voiddeleteDirectory(java.io.File dir)Delete a directory and all contents under it.static voiddeleteDirectory(java.nio.file.Path dir)Delete a directory and all contents under it.static voiddeleteFile(java.io.File path)Delete a file.static voiddeleteFile(java.nio.file.Path path)Delete a file.static voidensureDeleted(java.io.File dir)Ensure the provided directory does not exist, delete it if presentstatic voidensureDeleted(java.nio.file.Path dir)Ensure the provided directory does not exist, delete it if presentstatic voidensureDirExists(java.io.File dir)Ensure that directory exists, create it if not present.static voidensureDirExists(java.nio.file.Path dir)Ensure that directory exists, create it if not present.static voidensureEmpty(java.io.File dir)Ensure the provided directory exists, and contains no content (empty)static voidensureEmpty(java.nio.file.Path dir)Ensure the provided directory exists, and contains no content (empty)static voidensureEmpty(TestingDir testingdir)Ensure the provided directory exists, and contains no content (empty)protected static booleanisTestingDir(java.io.File dir)Internal class used to detect if the directory is a valid testing directory.protected static booleanisTestingDir(java.nio.file.Path dir)Internal class used to detect if the directory is a valid testing directory.private static voidrecursiveDeleteDir(java.nio.file.Path path)static voidtouch(java.io.File file)Create an empty file at the location.static voidtouch(java.nio.file.Path file)Create an empty file at the location.
-
-
-
Method Detail
-
delete
public static void delete(java.nio.file.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(java.io.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(java.io.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(java.nio.file.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(java.io.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(java.nio.file.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(java.nio.file.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(java.nio.file.Path path)
-
cleanDirectory
public static void cleanDirectory(java.io.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(java.nio.file.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(java.io.File dir)
Ensure the provided directory exists, and contains no content (empty)- Parameters:
dir- the dir to check.
-
ensureEmpty
public static void ensureEmpty(java.nio.file.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(java.io.File dir)
Ensure the provided directory does not exist, delete it if present- Parameters:
dir- the dir to check
-
ensureDeleted
public static void ensureDeleted(java.nio.file.Path dir)
Ensure the provided directory does not exist, delete it if present- Parameters:
dir- the dir to check
-
ensureDirExists
public static void ensureDirExists(java.io.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(java.nio.file.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(java.io.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(java.nio.file.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(java.io.File file) throws java.io.IOExceptionCreate 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:
java.io.IOException- if unable to create the new file.
-
touch
public static void touch(java.nio.file.Path file) throws java.io.IOExceptionCreate 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:
java.io.IOException- if unable to create the new file.
-
-