diff --git a/sandwich/src/Test/Sandwich/Formatters/TerminalUI/CrossPlatform.hs b/sandwich/src/Test/Sandwich/Formatters/TerminalUI/CrossPlatform.hs index 58465168..5ddb05d7 100644 --- a/sandwich/src/Test/Sandwich/Formatters/TerminalUI/CrossPlatform.hs +++ b/sandwich/src/Test/Sandwich/Formatters/TerminalUI/CrossPlatform.hs @@ -1,13 +1,23 @@ --- | +{-# LANGUAGE CPP #-} +{-# LANGUAGE QuasiQuotes #-} module Test.Sandwich.Formatters.TerminalUI.CrossPlatform ( openFileExplorerFolderPortable ) where import Control.Monad +import System.Directory import System.Process + -- | TODO: report exceptions here openFileExplorerFolderPortable :: String -> IO () +#ifdef mingw32_HOST_OS openFileExplorerFolderPortable folder = do + findExecutable "explorer.exe" >>= \case + Just p -> void $ readCreateProcessWithExitCode (proc p [folder]) "" + Nothing -> return () +#else +openFileExplorerFolderPortable folder = void $ readCreateProcessWithExitCode (proc "xdg-open" [folder]) "" +#endif