Package run.halo.gradle.utils
Class FileUtils
java.lang.Object
run.halo.gradle.utils.FileUtils
- Since:
- 2.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckDirectoryTraversal(String parentPath, String pathToCheck) Checks directory traversal vulnerability.static voidcheckDirectoryTraversal(Path parentPath, String pathToCheck) Checks directory traversal vulnerability.static voidcheckDirectoryTraversal(Path parentPath, Path pathToCheck) Checks directory traversal vulnerability.static voidcloseQuietly(Closeable closeable) static voidcloseQuietly(Closeable closeable, Consumer<IOException> consumer) Closes the givenCloseableas a null-safe operation while consuming IOException by the givenconsumer.static voidcopyRecursively(Path src, Path dest) static voidcreateIfAbsent(Path path) Creates directories if absent.static booleandeleteRecursively(Path root) static voidensureEmpty(Path path) The given path must be empty.static booleanChecks if the given path is empty.static voidunzip(ZipInputStream zis, Path targetPath)
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
unzip
- Throws:
IOException
-
copyRecursively
- Throws:
IOException
-
deleteRecursively
- Throws:
IOException
-
createIfAbsent
Creates directories if absent.- Parameters:
path- path must not be null- Throws:
IOException- io exception
-
ensureEmpty
The given path must be empty.- Parameters:
path- path must not be null- Throws:
IOException- io exception
-
isEmpty
Checks if the given path is empty.- Parameters:
path- path must not be null- Returns:
- true if the given path is empty; false otherwise
- Throws:
IOException- io exception
-
closeQuietly
-
closeQuietly
Closes the givenCloseableas a null-safe operation while consuming IOException by the givenconsumer.- Parameters:
closeable- The resource to close, may be null.consumer- Consumes the IOException thrown byCloseable.close().
-
checkDirectoryTraversal
Checks directory traversal vulnerability.- Parameters:
parentPath- parent path must not be null.pathToCheck- path to check must not be null
-
checkDirectoryTraversal
Checks directory traversal vulnerability.- Parameters:
parentPath- parent path must not be null.pathToCheck- path to check must not be null
-
checkDirectoryTraversal
Checks directory traversal vulnerability.- Parameters:
parentPath- parent path must not be null.pathToCheck- path to check must not be null
-