From 856392a6e1c33277dec086b7d7b9b3c613d7653d Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Thu, 5 Jul 2018 18:55:44 +0300 Subject: [PATCH] [util][no-java] added File.equals/.hashCode --- .../main/kotlin/org/jetbrains/kotlin/konan/file/File.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/file/File.kt b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/file/File.kt index 0ac8b870395..d6cb3510dcb 100644 --- a/shared/src/main/kotlin/org/jetbrains/kotlin/konan/file/File.kt +++ b/shared/src/main/kotlin/org/jetbrains/kotlin/konan/file/File.kt @@ -152,10 +152,17 @@ data class File constructor(internal val javaPath: Path) { val javaHome get() = File(System.getProperty("java.home")) - + val pathSeparator = java.io.File.pathSeparator } fun readStrings() = mutableListOf().also { list -> forEachLine{list.add(it)}} + + override fun equals(other: Any?): Boolean { + val otherFile = other as? File ?: return false + return otherFile.javaPath.toAbsolutePath() == javaPath.toAbsolutePath() + } + + override fun hashCode() = javaPath.toAbsolutePath().hashCode() } fun String.File(): File = File(this)