From f692c78977635cca980f725d61c2ad3ef1d37ffc Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta <francygazz@gmail.com> Date: Mon, 8 Oct 2018 10:46:19 +0200 Subject: [PATCH] Add doesPathExist to compat module --- Cabal/Distribution/Compat/Directory.hs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Cabal/Distribution/Compat/Directory.hs b/Cabal/Distribution/Compat/Directory.hs index 3fcd64f3d8..6bc4b07b86 100644 --- a/Cabal/Distribution/Compat/Directory.hs +++ b/Cabal/Distribution/Compat/Directory.hs @@ -1,8 +1,17 @@ {-# LANGUAGE CPP #-} -module Distribution.Compat.Directory (listDirectory, makeAbsolute) where - +module Distribution.Compat.Directory +( listDirectory +, makeAbsolute +, doesPathExist +) where + +#if MIN_VERSION_directory(1,2,7) +import System.Directory as Dir hiding (doesPathExist) +import System.Directory (doesPathExist) +#else import System.Directory as Dir +#endif #if !MIN_VERSION_directory(1,2,2) import System.FilePath as Path #endif @@ -25,3 +34,11 @@ makeAbsolute p | Path.isAbsolute p = return p return $ cwd </> p #endif + +#if !MIN_VERSION_directory(1,2,7) + +doesPathExist :: FilePath -> IO Bool +doesPathExist path = (||) <$> doesDirectoryExist path <*> doesFileExist path + +#endif + -- GitLab