Move Path.tryCreateSymbolicLinkTo to AbstractPathTest.kt
This commit is contained in:
committed by
Space
parent
81d6fea0c4
commit
f0da420b1f
@@ -8,6 +8,7 @@ package kotlin.jdk7.test
|
||||
import java.io.IOException
|
||||
import java.nio.file.*
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import kotlin.io.path.createSymbolicLinkPointingTo
|
||||
import kotlin.io.path.deleteIfExists
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.test.*
|
||||
@@ -50,6 +51,16 @@ abstract class AbstractPathTest {
|
||||
}
|
||||
}
|
||||
|
||||
fun Path.tryCreateSymbolicLinkTo(original: Path): Path? {
|
||||
return try {
|
||||
this.createSymbolicLinkPointingTo(original)
|
||||
} catch (e: Exception) {
|
||||
// the underlying OS may not support symbolic links or may require a privilege
|
||||
println("Creating a symbolic link failed with $e")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun withRestrictedRead(vararg paths: Path, block: () -> Unit) {
|
||||
try {
|
||||
if (paths.all { it.toFile().setReadable(false) }) {
|
||||
|
||||
Reference in New Issue
Block a user