module XDG
  ( getStateDir
  , getConfigDir
  , getConfigFile
  , getRepoDir
  ) where

import System.Directory (getXdgDirectory, XdgDirectory(..))
import System.FilePath ((</>))
import Types (appName)

-- | Get the XDG state directory for the application
getStateDir :: IO FilePath
getStateDir :: IO FilePath
getStateDir = XdgDirectory -> FilePath -> IO FilePath
getXdgDirectory XdgDirectory
XdgState FilePath
appName

-- | Get the XDG config directory for the application
getConfigDir :: IO FilePath
getConfigDir :: IO FilePath
getConfigDir = XdgDirectory -> FilePath -> IO FilePath
getXdgDirectory XdgDirectory
XdgConfig FilePath
appName

-- | Get the path to the config file
getConfigFile :: IO FilePath
getConfigFile :: IO FilePath
getConfigFile = do
  dir <- IO FilePath
getConfigDir
  return $ dir </> "config.yaml"

-- | Get the default repository directory
getRepoDir :: IO FilePath
getRepoDir :: IO FilePath
getRepoDir = do
  stateDir <- IO FilePath
getStateDir
  return $ stateDir </> "stackage-snapshots"