make opening file browser work on windows
This commit is contained in:
parent
2e48dcf6a7
commit
fc3a9a8adb
1 changed files with 14 additions and 8 deletions
|
@ -118,21 +118,27 @@ getFileBrowserR = whenM openFileBrowser redirectBack
|
||||||
openFileBrowser :: Handler Bool
|
openFileBrowser :: Handler Bool
|
||||||
openFileBrowser = do
|
openFileBrowser = do
|
||||||
path <- liftAnnex $ fromRepo Git.repoPath
|
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
|
( do
|
||||||
void $ liftIO $ forkIO $ void $
|
void $ liftIO $ forkIO $ void $
|
||||||
boolSystem cmd [Param path]
|
boolSystem cmd params
|
||||||
return True
|
return True
|
||||||
, do
|
, do
|
||||||
void $ redirect $ "file://" ++ path
|
void $ redirect $ "file://" ++ path
|
||||||
return False
|
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
|
{- Transfer controls. The GET is done in noscript mode and redirects back
|
||||||
- to the referring page. The POST is called by javascript. -}
|
- to the referring page. The POST is called by javascript. -}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue