Merge pull request #112 from maoe/testpath

Add `testpath`. Fixes #111
This commit is contained in:
Gabriel Gonzalez 2015-10-12 06:41:40 -07:00
commit 89d9e5e569

View file

@ -132,6 +132,7 @@ module Turtle.Prelude (
, rmtree , rmtree
, testfile , testfile
, testdir , testdir
, testpath
, date , date
, datefile , datefile
, touch , touch
@ -680,6 +681,14 @@ testfile path = liftIO (Filesystem.isFile path)
testdir :: MonadIO io => FilePath -> io Bool testdir :: MonadIO io => FilePath -> io Bool
testdir path = liftIO (Filesystem.isDirectory path) testdir path = liftIO (Filesystem.isDirectory path)
-- | Check if a path exists
testpath :: MonadIO io => FilePath -> io Bool
testpath path = do
exists <- testfile path
if exists
then return exists
else testdir path
{-| Touch a file, updating the access and modification times to the current time {-| Touch a file, updating the access and modification times to the current time
Creates an empty file if it does not exist Creates an empty file if it does not exist