mirror of
https://github.com/apple/pkl.git
synced 2026-07-06 21:15:12 +02:00
Added support for an alternative current dir mode in pkldoc (#824)
Some systems have trouble with handling symlinks, which breaks the current directory links created by Pkldoc. In this PR, we add an alternative mode which creates a full copy of the latest published version contents in the current directory instead. Co-authored-by: Dan Chao <dan.chao@apple.com>
This commit is contained in:
@@ -20,6 +20,9 @@ import java.nio.charset.Charset
|
||||
import java.nio.file.*
|
||||
import java.nio.file.attribute.FileAttribute
|
||||
import java.util.stream.Stream
|
||||
import kotlin.io.path.copyTo
|
||||
import kotlin.io.path.createParentDirectories
|
||||
import kotlin.io.path.exists
|
||||
|
||||
// not stored to avoid build-time initialization by native-image
|
||||
val currentWorkingDir: Path
|
||||
@@ -51,6 +54,19 @@ fun Path.writeString(
|
||||
@Throws(IOException::class)
|
||||
fun Path.readString(charset: Charset = Charsets.UTF_8): String = Files.readString(this, charset)
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun Path.copyRecursively(target: Path) {
|
||||
if (exists()) {
|
||||
target.createParentDirectories()
|
||||
walk().use { paths ->
|
||||
paths.forEach { src ->
|
||||
val dst = target.resolve(this@copyRecursively.relativize(src))
|
||||
src.copyTo(dst, overwrite = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val isWindows by lazy { System.getProperty("os.name").contains("Windows") }
|
||||
|
||||
/** Copy implementation from IoUtils.toNormalizedPathString */
|
||||
|
||||
Reference in New Issue
Block a user