module System.FSNotify.Devel
( treeExtAny, treeExtExists,
doAllEvents,
allEvents, existsEvents
) where
import Prelude hiding (FilePath, catch)
import Data.Text
import Filesystem.Path.CurrentOS
import System.FSNotify
treeExtExists :: WatchManager
-> FilePath
-> Text
-> (FilePath -> IO ())
-> IO ()
treeExtExists man dir ext action =
watchTree man dir (existsEvents $ flip hasExtension ext) (doAllEvents action)
treeExtAny :: WatchManager
-> FilePath
-> Text
-> (FilePath -> IO ())
-> IO ()
treeExtAny man dir ext action =
watchTree man dir (existsEvents $ flip hasExtension ext) (doAllEvents action)
doAllEvents :: Monad m => (FilePath -> m ()) -> Event -> m ()
doAllEvents action event =
case event of
Added f _ -> action f
Modified f _ -> action f
Removed f _ -> action f
existsEvents :: (FilePath -> Bool) -> (Event -> Bool)
existsEvents filt event =
case event of
Added f _ -> filt f
Modified f _ -> filt f
Removed _ _ -> False
allEvents :: (FilePath -> Bool) -> (Event -> Bool)
allEvents filt event =
case event of
Added f _ -> filt f
Modified f _ -> filt f
Removed f _ -> filt f