diff options
author | Gauvain 'GovanifY' Roussel-Tarbouriech <gauvain@govanify.com> | 2020-12-05 23:02:44 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-18 13:46:19 -0500 |
commit | 763d28551de32377a1dca8bdde02979e3686f400 (patch) | |
tree | b96de6da511d3fc2f7b29260d8250afb787df758 /ghc/GHCi | |
parent | 2adfb404111c220ef4df0206d9cda20c2fe5db46 (diff) | |
download | haskell-763d28551de32377a1dca8bdde02979e3686f400.tar.gz |
directory: ensure xdg compliance (Fix #6077)
Diffstat (limited to 'ghc/GHCi')
-rw-r--r-- | ghc/GHCi/UI.hs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 97b5f57447..18a6e6eeae 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -587,7 +587,21 @@ ghciLogAction lastErrLocations old_log_action withGhcAppData :: (FilePath -> IO a) -> IO a -> IO a withGhcAppData right left = do - either_dir <- tryIO (getAppUserDataDirectory "ghc") + either_dir <- tryIO (getXdgDirectory XdgData "ghc") + case either_dir of + Right dir -> + do createDirectoryIfMissing False dir `catchIO` \_ -> return () + right dir + _ -> left + +withGhcConfig :: (FilePath -> IO a) -> IO a -> IO a +withGhcConfig right left = do + old_path <- getAppUserDataDirectory "ghc" + use_old_path <- doesPathExist old_path + let path = (if use_old_path + then getAppUserDataDirectory "ghc" + else getXdgDirectory XdgConfig "ghc") + either_dir <- tryIO (path) case either_dir of Right dir -> do createDirectoryIfMissing False dir `catchIO` \_ -> return () @@ -600,7 +614,7 @@ runGHCi paths maybe_exprs = do let ignore_dot_ghci = gopt Opt_IgnoreDotGhci dflags - app_user_dir = liftIO $ withGhcAppData + app_user_dir = liftIO $ withGhcConfig (\dir -> return (Just (dir </> "ghci.conf"))) (return Nothing) |