From a0bfdbd8cc365cb11c26e81ee7587f0ec25df79d Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Mon, 14 Jul 2014 15:00:33 +0400 Subject: Location services, formatting services, initial self-documentation output. --- src/Utilities/Path.kt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/Utilities/Path.kt (limited to 'src/Utilities') diff --git a/src/Utilities/Path.kt b/src/Utilities/Path.kt new file mode 100644 index 00000000..5498d36e --- /dev/null +++ b/src/Utilities/Path.kt @@ -0,0 +1,21 @@ +package org.jetbrains.dokka + +import java.io.* + +fun File.getRelativePath(name: File): File { + val parent = getParentFile() + + if (parent == null) + throw IOException("No common directory"); + + val basePath = getCanonicalPath(); + val targetPath = name.getCanonicalPath(); + + if (targetPath.startsWith(basePath)) { + return File(targetPath.substring(basePath.length() + 1)) + } else { + return File(".." + File.separator + parent.getRelativePath(name)) + } +} + +fun File.appendExtension(extension: String) = File(getPath() + "." + extension) -- cgit