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

io.gitlab.arturbosch.detekt.test.FileExtension.kt Maven / Gradle / Ivy

There is a newer version: 1.23.7
Show newest version
package io.gitlab.arturbosch.detekt.test

import java.nio.file.Files
import java.nio.file.Path

/**
 * Creates an empty file in the default temporary-file directory, using
 * the given [prefix] and [suffix] to generate its name.
 * The resulting file in the returned path is automatically deleted on JVM exit.
 */
fun createTempFileForTest(prefix: String, suffix: String): Path {
    val path = Files.createTempFile(prefix, suffix)
    path.toFile().deleteOnExit()
    return path
}

/**
 * Creates a new directory in the default temporary-file directory, using
 * the given [prefix] to generate its name.
 * The resulting directory in the returned path is automatically deleted on JVM exit.
 */
fun createTempDirectoryForTest(prefix: String): Path {
    val dir = Files.createTempDirectory(prefix)
    dir.toFile().deleteOnExit()
    return dir
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy