in tools/copyRWrapper/src/CopyRWrapper.kt [25:55]
fun main(args: Array<String>) {
val rwrapperDirectory = File(args[0])
val destinationDirectory = File(args[1])
val customRWrapperPath = if (args.size > 2) File(args[2]) else null
if (customRWrapperPath == null && !System.getProperty("os.name").startsWith("windows", ignoreCase = true)) {
"./build_rwrapper.sh".runCommand(rwrapperDirectory)
}
destinationDirectory.mkdirs()
rwrapperDirectory
.takeIf { it.exists() && it.isDirectory }
?.list { _, name -> name.startsWith("rwrapper") || name.startsWith("R-") ||
name == "R" || name.startsWith("fsnotifier-") || name == "rkernelVersion.txt" }
?.map { Paths.get(rwrapperDirectory.toString(), it).toFile() }
?.forEach {
if (it.isDirectory) {
FileUtils.copyDirectoryToDirectory(it, destinationDirectory)
} else {
FileUtils.copyFileToDirectory(it, destinationDirectory)
}
} ?: check(false) { "cannot find directory: ${rwrapperDirectory}" }
customRWrapperPath
?.takeIf { it.exists() && it.isDirectory }
?.list { _, name -> name.startsWith("rwrapper") || name.startsWith("fsnotifier-") || name == "rkernelVersion.txt" }
?.map { Paths.get(customRWrapperPath.toString(), it).toFile() }
?.forEach {
FileUtils.copyFileToDirectory(it, destinationDirectory)
} ?: check(customRWrapperPath == null ) { "cannot find directory: ${customRWrapperPath}" }
}