{-# LANGUAGE CPP #-}
module Test.Sandwich.Formatters.TerminalUI.CrossPlatform (
openFileExplorerFolderPortable
) where
import Control.Monad
import System.Process
#ifdef mingw32_HOST_OS
import System.Directory
openFileExplorerFolderPortable :: String -> IO ()
openFileExplorerFolderPortable folder = do
findExecutable "explorer.exe" >>= \case
Just p -> void $ readCreateProcessWithExitCode (proc p [folder]) ""
Nothing -> return ()
#elif darwin_HOST_OS
openFileExplorerFolderPortable :: String -> IO ()
openFileExplorerFolderPortable folder =
void $ readCreateProcessWithExitCode (proc "open" [folder]) ""
#else
openFileExplorerFolderPortable :: String -> IO ()
openFileExplorerFolderPortable :: String -> IO ()
openFileExplorerFolderPortable String
folder =
IO (ExitCode, String, String) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (ExitCode, String, String) -> IO ())
-> IO (ExitCode, String, String) -> IO ()
forall a b. (a -> b) -> a -> b
$ CreateProcess -> String -> IO (ExitCode, String, String)
readCreateProcessWithExitCode (String -> [String] -> CreateProcess
proc String
"xdg-open" [String
folder]) String
""
#endif