make opening file browser work on windows

This commit is contained in:
Joey Hess 2013-12-09 16:39:10 -04:00
parent 2e48dcf6a7
commit fc3a9a8adb

View file

@ -118,21 +118,27 @@ getFileBrowserR = whenM openFileBrowser redirectBack
openFileBrowser :: Handler Bool
openFileBrowser = do
path <- liftAnnex $ fromRepo Git.repoPath
ifM (liftIO $ inPath cmd <&&> inPath cmd)
#ifdef darwin_HOST_OS
let cmd = "open"
let params = [Param path]
#else
#ifdef mingw32_HOST_OS
let cmd = "cmd"
let params = [Param $ "/c start " ++ path]
#else
let cmd = "xdg-open"
let params = [Param path]
#endif
#endif
ifM (liftIO $ inPath cmd)
( do
void $ liftIO $ forkIO $ void $
boolSystem cmd [Param path]
boolSystem cmd params
return True
, do
void $ redirect $ "file://" ++ path
return False
)
where
#ifdef darwin_HOST_OS
cmd = "open"
#else
cmd = "xdg-open"
#endif
{- Transfer controls. The GET is done in noscript mode and redirects back
- to the referring page. The POST is called by javascript. -}