Class FileUtils

java.lang.Object
run.halo.gradle.utils.FileUtils

public abstract class FileUtils extends Object
Since:
2.0.0
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • unzip

      public static void unzip(ZipInputStream zis, Path targetPath) throws IOException
      Throws:
      IOException
    • copyRecursively

      public static void copyRecursively(Path src, Path dest) throws IOException
      Throws:
      IOException
    • deleteRecursively

      public static boolean deleteRecursively(Path root) throws IOException
      Throws:
      IOException
    • createIfAbsent

      public static void createIfAbsent(Path path) throws IOException
      Creates directories if absent.
      Parameters:
      path - path must not be null
      Throws:
      IOException - io exception
    • ensureEmpty

      public static void ensureEmpty(Path path) throws IOException
      The given path must be empty.
      Parameters:
      path - path must not be null
      Throws:
      IOException - io exception
    • isEmpty

      public static boolean isEmpty(Path path) throws IOException
      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

      public static void closeQuietly(Closeable closeable)
    • closeQuietly

      public static void closeQuietly(Closeable closeable, Consumer<IOException> consumer)
      Closes the given Closeable as a null-safe operation while consuming IOException by the given consumer.
      Parameters:
      closeable - The resource to close, may be null.
      consumer - Consumes the IOException thrown by Closeable.close().
    • checkDirectoryTraversal

      public static void checkDirectoryTraversal(Path parentPath, Path pathToCheck)
      Checks directory traversal vulnerability.
      Parameters:
      parentPath - parent path must not be null.
      pathToCheck - path to check must not be null
    • checkDirectoryTraversal

      public static void checkDirectoryTraversal(String parentPath, String pathToCheck)
      Checks directory traversal vulnerability.
      Parameters:
      parentPath - parent path must not be null.
      pathToCheck - path to check must not be null
    • checkDirectoryTraversal

      public static void checkDirectoryTraversal(Path parentPath, String pathToCheck)
      Checks directory traversal vulnerability.
      Parameters:
      parentPath - parent path must not be null.
      pathToCheck - path to check must not be null