Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XDG directories #3456

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion idris.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Library
, cheapskate < 0.2
, containers >= 0.5 && < 0.6
, deepseq < 1.5
, directory >= 1.2.2.0 && < 1.2.3.0 || > 1.2.3.0
, directory > 1.2.3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bound should be directory >= 1.2.3, if I understand the situation correctly.

, filepath < 1.5
, fingertree >= 0.1 && < 0.2
, haskeline >= 0.7 && < 0.8
Expand Down
9 changes: 7 additions & 2 deletions src/Idris/Info.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Idris.Info
, getIdrisCC
, getIdrisVersion
, getIdrisVersionNoGit
, getIdrisUserConfigDir
, getIdrisUserDataDir
, getIdrisInitScript
, getIdrisHistoryFile
Expand Down Expand Up @@ -68,9 +69,13 @@ getIdrisVersion = showVersion S.version ++ suffix
getIdrisVersionNoGit = S.version


-- | Get the platform-specific, user-specific Idris dir
-- | Get the platform-specific, user-specific Idris configuration dir
getIdrisUserConfigDir :: IO FilePath
getIdrisUserConfigDir = getXdgDirectory XdgConfig "idris"

-- | Get the platform-specific, user-specific Idris data dir
getIdrisUserDataDir :: IO FilePath
getIdrisUserDataDir = getAppUserDataDirectory "idris"
getIdrisUserDataDir = getXdgDirectory XdgData "idris"

-- | Locate the platform-specific location for the init script
getIdrisInitScript :: IO FilePath
Expand Down
4 changes: 3 additions & 1 deletion src/Idris/Info/Show.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ showIdrisInfo = do

putStrLn "Paths:"
ldir <- getIdrisLibDir
cdir <- getIdrisUserConfigDir
udir <- getIdrisUserDataDir
ddir <- getIdrisDocDir
idir <- getIdrisDataDir
Expand All @@ -116,7 +117,8 @@ showIdrisInfo = do
putStrLn $ unwords ["-", "Library Dir:", ldir]
putStrLn $ unwords ["-", "C RTS Dir:", crdir]
putStrLn $ unwords ["-", "JS RTS Dir:", jrdir]
putStrLn $ unwords ["-", "User Dir:", udir]
putStrLn $ unwords ["-", "User Data Config:", cdir]
putStrLn $ unwords ["-", "User Data Dir:", udir]
putStrLn $ unwords ["-", "Documentation Dir:", ddir]

putStrLn "Flags:"
Expand Down
11 changes: 6 additions & 5 deletions src/Idris/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ idrisMain opts =
Just expr -> execScript expr

-- Create Idris data dir + repl history and config dir
idrisCatch (do dir <- runIO $ getIdrisUserDataDir
exists <- runIO $ doesDirectoryExist dir
unless exists $ logLvl 1 ("Creating " ++ dir)
runIO $ createDirectoryIfMissing True (dir </> "repl"))
(\e -> return ())
sequence_ $
[idrisCatch (do dir <- runIO $ getDir
exists <- runIO $ doesDirectoryExist dir
unless exists $ logLvl 1 ("Creating " ++ dir)
runIO $ createDirectoryIfMissing True (dir </> "repl"))
(\e -> return ()) | getDir <- [getIdrisUserConfigDir, getIdrisUserDataDir]]

historyFile <- runIO $ getIdrisHistoryFile

Expand Down