aboutsummaryrefslogtreecommitdiff
path: root/src/Utilities
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-14 15:00:33 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-14 15:00:33 +0400
commita0bfdbd8cc365cb11c26e81ee7587f0ec25df79d (patch)
treec68610d2003d2a4712b3fbc95561ac20390a161d /src/Utilities
parent6168541bd5bb141c40a1e2a909afa84441b35ed5 (diff)
downloaddokka-a0bfdbd8cc365cb11c26e81ee7587f0ec25df79d.tar.gz
dokka-a0bfdbd8cc365cb11c26e81ee7587f0ec25df79d.tar.bz2
dokka-a0bfdbd8cc365cb11c26e81ee7587f0ec25df79d.zip
Location services, formatting services, initial self-documentation output.
Diffstat (limited to 'src/Utilities')
-rw-r--r--src/Utilities/Path.kt21
1 files changed, 21 insertions, 0 deletions
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)