Skip to content

Commit 856392a

Browse files
committed
[util][no-java] added File.equals/.hashCode
1 parent da7e31a commit 856392a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • shared/src/main/kotlin/org/jetbrains/kotlin/konan/file

shared/src/main/kotlin/org/jetbrains/kotlin/konan/file/File.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,17 @@ data class File constructor(internal val javaPath: Path) {
152152

153153
val javaHome
154154
get() = File(System.getProperty("java.home"))
155-
155+
val pathSeparator = java.io.File.pathSeparator
156156
}
157157

158158
fun readStrings() = mutableListOf<String>().also { list -> forEachLine{list.add(it)}}
159+
160+
override fun equals(other: Any?): Boolean {
161+
val otherFile = other as? File ?: return false
162+
return otherFile.javaPath.toAbsolutePath() == javaPath.toAbsolutePath()
163+
}
164+
165+
override fun hashCode() = javaPath.toAbsolutePath().hashCode()
159166
}
160167

161168
fun String.File(): File = File(this)

0 commit comments

Comments
 (0)