Make FileAccess.createLink accept FileAccess' only

This commit is contained in:
JeremyStar™ 2024-12-16 02:37:09 +01:00
parent f0c43d7b53
commit ce7bd233b6
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -618,12 +618,12 @@ class FileAccess {
* @since v1-alpha10
*/
@Throws(IOAccessException::class)
fun createLink(destination: String, hard: Boolean): FileAccess {
fun createLink(destination: FileAccess, hard: Boolean): FileAccess {
if (!exists())
try {
logger.diag("Creating a ${if (hard) "hard" else "symbolic"} link at '${unformatFromPath(path)}'")
if (hard) Files.createLink(path, formatToPath(destination))
else Files.createSymbolicLink(path, formatToPath(destination))
if (hard) Files.createLink(path, destination.path)
else Files.createSymbolicLink(path, destination.path)
} catch (exception: Exception) {
throw IOAccessException("Unable to create a new ${if (hard) "hard" else "symbolic"} link at '${unformatFromPath(path)}'", exception)
}