Class FS
- java.lang.Object
-
- org.eclipse.jetty.toolchain.test.FS
-
public final class FS extends java.lang.Object
Common FileSystem utility methods
-
-
Constructor Summary
Constructors Modifier Constructor Description private
FS()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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.static void
delete(java.io.File path)
Delete a file or a directory.static void
delete(java.nio.file.Path path)
Delete a file or a directory.static void
deleteDir(java.nio.file.Path path)
Delete a directory.static void
deleteDirectory(java.io.File dir)
Delete a directory and all contents under it.static void
deleteDirectory(java.nio.file.Path dir)
Delete a directory and all contents under it.static void
deleteFile(java.io.File path)
Delete a file.static void
deleteFile(java.nio.file.Path path)
Delete a file.static void
ensureDeleted(java.io.File dir)
Ensure the provided directory does not exist, delete it if presentstatic void
ensureDeleted(java.nio.file.Path dir)
Ensure the provided directory does not exist, delete it if presentstatic void
ensureDirExists(java.io.File dir)
Ensure that directory exists, create it if not present.static void
ensureDirExists(java.nio.file.Path dir)
Ensure that directory exists, create it if not present.static void
ensureEmpty(java.io.File dir)
Ensure the provided directory exists, and contains no content (empty)static void
ensureEmpty(java.nio.file.Path dir)
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
isTestingDir(java.io.File dir)
Internal class used to detect if the directory is a valid testing directory.protected static boolean
isTestingDir(java.nio.file.Path dir)
Internal class used to detect if the directory is a valid testing directory.private static void
recursiveDeleteDir(java.nio.file.Path path)
static void
touch(java.io.File file)
Create an empty file at the location.static void
touch(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.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:
java.io.IOException
- if unable to create the new file.
-
touch
public static void touch(java.nio.file.Path file) throws java.io.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:
java.io.IOException
- if unable to create the new file.
-
-