module System.Directory.ProjectRoot
where
import Control.Monad ((<=<), (>=>))
import Foreign.C
import System.Directory (getCurrentDirectory)
getProjectRoot :: FilePath -> IO FilePath
getProjectRoot = (find_project_root <=< newCString) >=> peekCString
getProjectRootWeighted :: FilePath -> IO FilePath
getProjectRootWeighted = (find_project_root_weighted <=< newCString) >=>
peekCString
getProjectRootCurrent :: IO FilePath
getProjectRootCurrent = getCurrentDirectory >>= getProjectRoot
getProjectRootWeightedCurrent :: IO FilePath
getProjectRootWeightedCurrent = getCurrentDirectory >>= getProjectRootWeighted
foreign import ccall "find_project_root" find_project_root :: CString -> IO CString
foreign import ccall "find_project_root_weighted" find_project_root_weighted :: CString -> IO CString