module System.FSNotify.Devel
( treeExtAny, treeExtExists,
doAllEvents,
allEvents, existsEvents
) where
import Data.Text
import Prelude hiding (FilePath)
import System.FSNotify
import System.FSNotify.Path (hasThisExtension)
import System.FilePath
treeExtExists :: WatchManager
-> FilePath
-> Text
-> (FilePath -> IO ())
-> IO StopListening
treeExtExists :: WatchManager
-> FilePath -> Text -> (FilePath -> IO ()) -> IO (IO ())
treeExtExists man :: WatchManager
man dir :: FilePath
dir ext :: Text
ext action :: FilePath -> IO ()
action =
WatchManager -> FilePath -> ActionPredicate -> Action -> IO (IO ())
watchTree WatchManager
man FilePath
dir ((FilePath -> Bool) -> ActionPredicate
existsEvents ((FilePath -> Bool) -> ActionPredicate)
-> (FilePath -> Bool) -> ActionPredicate
forall a b. (a -> b) -> a -> b
$ (FilePath -> Text -> Bool) -> Text -> FilePath -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip FilePath -> Text -> Bool
hasThisExtension Text
ext) ((FilePath -> IO ()) -> Action
forall (m :: * -> *).
Monad m =>
(FilePath -> m ()) -> Event -> m ()
doAllEvents FilePath -> IO ()
action)
treeExtAny :: WatchManager
-> FilePath
-> Text
-> (FilePath -> IO ())
-> IO StopListening
treeExtAny :: WatchManager
-> FilePath -> Text -> (FilePath -> IO ()) -> IO (IO ())
treeExtAny man :: WatchManager
man dir :: FilePath
dir ext :: Text
ext action :: FilePath -> IO ()
action =
WatchManager -> FilePath -> ActionPredicate -> Action -> IO (IO ())
watchTree WatchManager
man FilePath
dir ((FilePath -> Bool) -> ActionPredicate
allEvents ((FilePath -> Bool) -> ActionPredicate)
-> (FilePath -> Bool) -> ActionPredicate
forall a b. (a -> b) -> a -> b
$ (FilePath -> Text -> Bool) -> Text -> FilePath -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip FilePath -> Text -> Bool
hasThisExtension Text
ext) ((FilePath -> IO ()) -> Action
forall (m :: * -> *).
Monad m =>
(FilePath -> m ()) -> Event -> m ()
doAllEvents FilePath -> IO ()
action)
doAllEvents :: Monad m => (FilePath -> m ()) -> Event -> m ()
doAllEvents :: (FilePath -> m ()) -> Event -> m ()
doAllEvents action :: FilePath -> m ()
action event :: Event
event =
case Event
event of
Added f :: FilePath
f _ _ -> FilePath -> m ()
action FilePath
f
Modified f :: FilePath
f _ _ -> FilePath -> m ()
action FilePath
f
Removed f :: FilePath
f _ _ -> FilePath -> m ()
action FilePath
f
Unknown f :: FilePath
f _ _ -> FilePath -> m ()
action FilePath
f
existsEvents :: (FilePath -> Bool) -> (Event -> Bool)
existsEvents :: (FilePath -> Bool) -> ActionPredicate
existsEvents filt :: FilePath -> Bool
filt event :: Event
event =
case Event
event of
Added f :: FilePath
f _ _ -> FilePath -> Bool
filt FilePath
f
Modified f :: FilePath
f _ _ -> FilePath -> Bool
filt FilePath
f
Removed _ _ _ -> Bool
False
Unknown _ _ _ -> Bool
False
allEvents :: (FilePath -> Bool) -> (Event -> Bool)
allEvents :: (FilePath -> Bool) -> ActionPredicate
allEvents filt :: FilePath -> Bool
filt event :: Event
event =
case Event
event of
Added f :: FilePath
f _ _ -> FilePath -> Bool
filt FilePath
f
Modified f :: FilePath
f _ _ -> FilePath -> Bool
filt FilePath
f
Removed f :: FilePath
f _ _ -> FilePath -> Bool
filt FilePath
f
Unknown f :: FilePath
f _ _ -> FilePath -> Bool
filt FilePath
f