Add testpath. Fixes #111

This commit is contained in:
Mitsutoshi Aoe 2015-10-11 21:14:22 -07:00
parent 0c7fc6bb86
commit 5529ccb435

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