hiernotify-2011.3.17: Notification library for a filesystem hierarchy.



This module offers a daemon polling a filesystem hierarchy to notify changes to a given IO action.

This example runs a n seconds console reporter for the activity in hierarchy p. Polling delay is 3 seconds. And it waits 2 silent polling samples before reporting to console.

Medium responsiveness for an isolated change is then 3 * (2 + 1/2) seconds

 testReport 	:: Int -- ^ life span for the program
		-> FilePath -- ^ hierarchy top
		-> IO () -- ^ block for life span
 testReport n p = do 
	k <- onDifferenceDaemon  3 2 (not . isPrefixOf ".") p  (print . report) -- boot the onDifferenceDaemon
	threadDelay $ n * 1000000 -- wait n seconds
	k -- kill the onDifferenceDaemon
	where report (Difference nn dd mm) = map length [nn,dd,mm]



data Difference Source

Difference datatype containing a difference as three sets of paths




created :: [FilePath]

Files appeared

deleted :: [FilePath]

Files disappeared

modified :: [FilePath]

Files modified



:: Int

polling delay in seconds

-> Int

number of no-change delays before running the action

-> (FilePath -> Bool)

path filter

-> FilePath

file hierarchy top

-> (Difference -> IO ())

the action executed on a modification

-> IO (IO ())

the action to kill the daemon

Execute an action on file changes in a hierarchy.