module HSInstall.Resources
( getRsrcDir )
where
import System.Directory ( doesDirectoryExist )
import System.Environment ( getExecutablePath )
import System.FilePath ( (</>), takeDirectory, takeFileName )
getRsrcDir :: IO FilePath -> IO FilePath
getRsrcDir cabalDataDir = do
appDir <- takeFileName <$> cabalDataDir
rsrcPath <- ( </> "share" </> appDir </> "resources" )
. takeDirectory . takeDirectory <$> getExecutablePath
rsrcPathExists <- doesDirectoryExist rsrcPath
if rsrcPathExists
then return rsrcPath
else fail "Unable to find resources directory"