-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve openFileExplorerFolderPortable on windows
- Loading branch information
Showing
1 changed file
with
11 additions
and
1 deletion.
There are no files selected for viewing
12 changes: 11 additions & 1 deletion
12
sandwich/src/Test/Sandwich/Formatters/TerminalUI/CrossPlatform.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |