From 5529ccb435dafc6b74036aa3f07b80a19930cb8b Mon Sep 17 00:00:00 2001 From: Mitsutoshi Aoe Date: Sun, 11 Oct 2015 21:14:22 -0700 Subject: [PATCH] Add `testpath`. Fixes #111 --- src/Turtle/Prelude.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Turtle/Prelude.hs b/src/Turtle/Prelude.hs index 5cd8e7c..13b76c4 100644 --- a/src/Turtle/Prelude.hs +++ b/src/Turtle/Prelude.hs @@ -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