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
, testfile
, testdir
, testpath
, date
, datefile
, touch
@ -680,6 +681,14 @@ testfile path = liftIO (Filesystem.isFile path)
testdir :: MonadIO io => FilePath -> io Bool
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
Creates an empty file if it does not exist