From a9aa532d5f3f3fc4f08982eaabe9809a405236fb Mon Sep 17 00:00:00 2001 From: AmirHossein Abdolmotallebi Date: Tue, 7 Jan 2025 16:27:05 +0330 Subject: [PATCH] force wrap file path by quotes (#351) --- .../kotlin/ir/amirab/util/osfileutil/WindowsFileUtils.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shared/utils/src/main/kotlin/ir/amirab/util/osfileutil/WindowsFileUtils.kt b/shared/utils/src/main/kotlin/ir/amirab/util/osfileutil/WindowsFileUtils.kt index 061f30f..856c9b3 100644 --- a/shared/utils/src/main/kotlin/ir/amirab/util/osfileutil/WindowsFileUtils.kt +++ b/shared/utils/src/main/kotlin/ir/amirab/util/osfileutil/WindowsFileUtils.kt @@ -10,7 +10,7 @@ import java.io.File internal class WindowsFileUtils : FileUtilsBase() { override fun openFileInternal(file: File): Boolean { - return execAndWait(arrayOf("cmd", "/c", "start", "/B", "", file.path)) + return execAndWait(arrayOf("cmd", "/c", "start", "/B", "", file.path.quoted())) } override fun openFolderOfFileInternal(file: File): Boolean { @@ -19,7 +19,7 @@ internal class WindowsFileUtils : FileUtilsBase() { return true } //fallback to use explorer - return execAndWait(arrayOf("cmd", "/c", "explorer.exe", "/select,", file.path)) + return execAndWait(arrayOf("cmd", "/c", "explorer.exe", "/select,", file.path.quoted())) } override fun openFolderInternal(folder: File): Boolean { @@ -28,7 +28,7 @@ internal class WindowsFileUtils : FileUtilsBase() { return true } //fallback to use explorer - return execAndWait(arrayOf("cmd", "/c", "explorer.exe", folder.path)) + return execAndWait(arrayOf("cmd", "/c", "explorer.exe", folder.path.quoted())) } private fun showFileInFolderViaNative( @@ -72,6 +72,9 @@ internal class WindowsFileUtils : FileUtilsBase() { return false } } + + private fun String.quoted() = "\"$this\"" + }