diff options
author | Mike Hearn <mike@plan99.net> | 2015-11-23 18:53:18 +0100 |
---|---|---|
committer | Mike Hearn <mike@plan99.net> | 2015-11-23 18:53:18 +0100 |
commit | 23e270b603eb32472b8ef4a5f44c01af57fd049f (patch) | |
tree | 05bee49e890a8e71ef86588951be39ffba4a4178 | |
parent | e7aeb481697a2b295b8c1f49102642caec11a34a (diff) | |
download | dokka-23e270b603eb32472b8ef4a5f44c01af57fd049f.tar.gz dokka-23e270b603eb32472b8ef4a5f44c01af57fd049f.tar.bz2 dokka-23e270b603eb32472b8ef4a5f44c01af57fd049f.zip |
Use Java 8 Path API to relativize paths instead of rolling a custom version.
Fixes various IOExceptions thrown during generation.
-rw-r--r-- | src/Locations/LocationService.kt | 2 | ||||
-rw-r--r-- | src/Utilities/Path.kt | 14 |
2 files changed, 1 insertions, 15 deletions
diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt index 4f587361..15a4ebac 100644 --- a/src/Locations/LocationService.kt +++ b/src/Locations/LocationService.kt @@ -27,7 +27,7 @@ public data class FileLocation(val file: File): Location { return "." } val ownerFolder = file.parentFile!! - val relativePath = ownerFolder.getRelativePath(other.file).path + val relativePath = ownerFolder.toPath().relativize(other.file.toPath()).toString() return if (anchor == null) relativePath else relativePath + "#" + anchor } } diff --git a/src/Utilities/Path.kt b/src/Utilities/Path.kt index 36277d9f..05838499 100644 --- a/src/Utilities/Path.kt +++ b/src/Utilities/Path.kt @@ -1,19 +1,5 @@ package org.jetbrains.dokka import java.io.File -import java.io.IOException - -fun File.getRelativePath(name: File): File { - val parent = parentFile ?: throw IOException("No common directory") - - val basePath = canonicalPath + File.separator; - val targetPath = name.canonicalPath; - - if (targetPath.startsWith(basePath)) { - return File(targetPath.substring(basePath.length)) - } else { - return File(".." + File.separator + parent.getRelativePath(name)) - } -} fun File.appendExtension(extension: String) = if (extension.isEmpty()) this else File(path + "." + extension) |