From eeab317a2895c8c2f4beacfc1b3ffba63b977064 Mon Sep 17 00:00:00 2001 From: chrislo27 Date: Sat, 26 Sep 2020 10:16:19 -0700 Subject: [PATCH] Fix a URI issue with spaces (illegal URI characters) --- .../io/github/chrislo27/toolboks/util/gdxutils/URIUtils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/kotlin/io/github/chrislo27/toolboks/util/gdxutils/URIUtils.kt b/core/src/main/kotlin/io/github/chrislo27/toolboks/util/gdxutils/URIUtils.kt index 45822e711..2025a3e5d 100644 --- a/core/src/main/kotlin/io/github/chrislo27/toolboks/util/gdxutils/URIUtils.kt +++ b/core/src/main/kotlin/io/github/chrislo27/toolboks/util/gdxutils/URIUtils.kt @@ -7,9 +7,9 @@ import java.io.File import java.net.URI -fun Net.openFileExplorer(absPath: String): Boolean { +fun Net.openFileExplorer(uri: URI): Boolean { return try { - Desktop.getDesktop().browse(URI("file:///${absPath.replace("\\", "/")}")) + Desktop.getDesktop().browse(uri) true } catch (t: Throwable) { t.printStackTrace() @@ -17,6 +17,6 @@ fun Net.openFileExplorer(absPath: String): Boolean { } } -fun Net.openFileExplorer(file: File): Boolean = openFileExplorer(file.absolutePath) +fun Net.openFileExplorer(file: File): Boolean = openFileExplorer(file.toURI()) fun Net.openFileExplorer(fileHandle: FileHandle): Boolean = openFileExplorer(fileHandle.file())