diff --git a/libraries/stdlib/jdk7/test/AbstractPathTest.kt b/libraries/stdlib/jdk7/test/AbstractPathTest.kt index 6111127f826..46a579e04ee 100644 --- a/libraries/stdlib/jdk7/test/AbstractPathTest.kt +++ b/libraries/stdlib/jdk7/test/AbstractPathTest.kt @@ -5,13 +5,11 @@ package kotlin.jdk7.test -import java.io.IOException -import java.nio.file.* -import java.nio.file.attribute.BasicFileAttributes +import java.nio.file.Path import kotlin.io.path.createSymbolicLinkPointingTo import kotlin.io.path.deleteIfExists -import kotlin.io.path.exists -import kotlin.test.* +import kotlin.io.path.deleteRecursively +import kotlin.test.AfterTest abstract class AbstractPathTest { private val cleanUpActions = mutableListOf Unit>>() @@ -22,24 +20,10 @@ abstract class AbstractPathTest { } fun Path.cleanupRecursively(): Path { - cleanUpActions.add(this to { - if (it.exists(LinkOption.NOFOLLOW_LINKS)) Files.walkFileTree(it, cleanupVisitor) - }) + cleanUpActions.add(this to { it.deleteRecursively() }) return this } - private val cleanupVisitor = object : SimpleFileVisitor() { - override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult { - file.deleteIfExists() - return super.visitFile(file, attrs) - } - - override fun postVisitDirectory(dir: Path, exc: IOException?): FileVisitResult { - dir.deleteIfExists() - return super.postVisitDirectory(dir, exc) - } - } - @AfterTest fun cleanUp() { for ((path, action) in cleanUpActions) {