All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jeppeman.globallydynamic.gradle.extensions.Path.kt Maven / Gradle / Ivy

Go to download

GloballyDynamic - Gradle plugin to facilitate for local dynamic delivery for Android.

There is a newer version: 1.9.0
Show newest version
package com.jeppeman.globallydynamic.gradle.extensions

import java.io.IOException
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes

internal fun Path.deleteCompletely() {
    if (Files.isDirectory(this)) {
        Files.walkFileTree(this, object : SimpleFileVisitor() {
            override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
                Files.delete(file)
                return FileVisitResult.CONTINUE
            }

            override fun postVisitDirectory(dir: Path, exc: IOException?): FileVisitResult {
                Files.delete(dir)
                return FileVisitResult.CONTINUE
            }
        })
    } else {
        Files.deleteIfExists(this)
    }
}

internal fun Path.unzip(destinationDir: String) = toFile().unzip(destinationDir)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy