Skip to content

Commit

Permalink
Improve openFileExplorerFolderPortable on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Oct 25, 2024
1 parent 2e19576 commit 6f2fbd8
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6f2fbd8

Please sign in to comment.