fix(komga-tray): use workaround to open filesystem on Windows

This commit is contained in:
Gauthier Roebroeck 2023-10-27 15:53:04 +08:00
parent 8171cb859e
commit 6059b85e4f

View file

@ -16,11 +16,13 @@ fun openUrl(url: String) {
fun openExplorer(file: File) { fun openExplorer(file: File) {
logger.info { "Try to open explorer for path: $file" } logger.info { "Try to open explorer for path: $file" }
if (Desktop.isDesktopSupported()) when {
Desktop.getDesktop().let { Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE_FILE_DIR) -> Desktop.getDesktop().browseFileDirectory(file)
if (it.isSupported(Desktop.Action.BROWSE_FILE_DIR)) it.browseFileDirectory(file) System.getProperty("os.name").startsWith("win", true) -> {
else logger.warn { "Cannot open explorer: Desktop.Action.BROWSE_FILE_DIR is not supported" } val command = """explorer.exe /select, "${file.absolutePath}""""
Runtime.getRuntime().exec(command)
}
else -> logger.warn { "Cannot open explorer, not supported" }
} }
else
logger.warn { "Cannot open explorer: Desktop is not supported" }
} }