Guest User

Untitled

a guest
Sep 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package com.julianjarecki.latextemplates.lib
  2.  
  3. import java.io.File
  4. import java.util.logging.Logger
  5.  
  6. enum class OS {
  7. Windows, OSX, Linux;
  8.  
  9. companion object {
  10. val current: OS = System.getProperty("os.name")
  11. .toLowerCase().run {
  12. when {
  13. startsWith("windows") -> Windows
  14. startsWith("linux") -> Linux
  15. else -> OSX
  16. }
  17. }
  18. }
  19. }
  20.  
  21. fun File.openInExplorer() {
  22. when (OS.current) {
  23. OS.Windows -> "explorer.exe /select,${absolutePath}".runCommand(parentFile)
  24. else -> Logger.getGlobal().info("currently not implemented on ${OS.current} (os.name = ${System.getProperty("os.name")})")
  25. }
  26. }
  27.  
  28. fun File.openWithDefaultApp() {
  29. when (OS.current) {
  30. OS.Windows -> "cmd /c \"start ${absolutePath}\"".runCommand(parentFile)
  31. else -> Logger.getGlobal().info("currently not implemented on ${OS.current} (os.name = ${System.getProperty("os.name")})")
  32. }
  33. }
Add Comment
Please, Sign In to add comment