Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.julianjarecki.latextemplates.lib
- import java.io.File
- import java.util.logging.Logger
- enum class OS {
- Windows, OSX, Linux;
- companion object {
- val current: OS = System.getProperty("os.name")
- .toLowerCase().run {
- when {
- startsWith("windows") -> Windows
- startsWith("linux") -> Linux
- else -> OSX
- }
- }
- }
- }
- fun File.openInExplorer() {
- when (OS.current) {
- OS.Windows -> "explorer.exe /select,${absolutePath}".runCommand(parentFile)
- else -> Logger.getGlobal().info("currently not implemented on ${OS.current} (os.name = ${System.getProperty("os.name")})")
- }
- }
- fun File.openWithDefaultApp() {
- when (OS.current) {
- OS.Windows -> "cmd /c \"start ${absolutePath}\"".runCommand(parentFile)
- else -> Logger.getGlobal().info("currently not implemented on ${OS.current} (os.name = ${System.getProperty("os.name")})")
- }
- }
Add Comment
Please, Sign In to add comment