@@ -92,7 +92,6 @@ module Streamly.Internal.FileSystem.Event.Darwin
93 -- ** Default configuration
93 -- ** Default configuration
94 Config (..)
94 Config (..)
96 , defaultConfig
95 , defaultConfig
98 -- ** Watch Behavior
97 -- ** Watch Behavior
@@ -192,7 +191,7 @@ import qualified Streamly.Internal.Data.Array.Unboxed as A
192-------------------------------------------------------------------------------
191-------------------------------------------------------------------------------
194-- XXX Add a recursive option to Config
193-- XXX Add a recursive option to Config
195−-- Keep setRecursiveMode Off as undefined for now until we implement it.
194+-- Keep setRecursiveMode False as undefined for now until we implement it.
197-- | Watch configuration, used to specify the events of interest and the
196-- | Watch configuration, used to specify the events of interest and the
198-- behavior of the watch.
197-- behavior of the watch.
@@ -233,28 +232,22 @@ setEventBatching :: BatchInfo -> Config -> Config
233setEventBatching batchInfo cfg =
232setEventBatching batchInfo cfg =
234 let (t, status) =
233 let (t, status) =
235 case batchInfo of
234 case batchInfo of
236− Throttle sec | sec < 0 -> (0, On)
235+ Throttle sec | sec < 0 -> (0, True)
237− Throttle sec -> (sec, On)
236+ Throttle sec -> (sec, True)
238− Batch sec | sec < 0 -> (0, Off)
237+ Batch sec | sec < 0 -> (0, False)
239− Batch sec -> (sec, Off)
238+ Batch sec -> (sec, False)
240 in setFlag kFSEventStreamCreateFlagNoDefer status $ cfg {latency = t}
239 in setFlag kFSEventStreamCreateFlagNoDefer status $ cfg {latency = t}
242-------------------------------------------------------------------------------
241-------------------------------------------------------------------------------
243-- Boolean settings
242-- Boolean settings
244-------------------------------------------------------------------------------
243-------------------------------------------------------------------------------
246−-- | Whether a setting is 'On' or 'Off'.
250−data Switch = On | Off
252−setFlag :: Word32 -> Switch -> Config -> Config
245+setFlag :: Word32 -> Bool -> Config -> Config
253setFlag mask status cfg@Config{..} =
246setFlag mask status cfg@Config{..} =
254 let flags =
247 let flags =
255− case status of
248+ if status
256− On -> createFlags .|. mask
249+ then createFlags .|. mask
257− Off -> createFlags .&. complement mask
250+ else createFlags .&. complement mask
258 in cfg {createFlags = flags}
251 in cfg {createFlags = flags}
260foreign import ccall safe
253foreign import ccall safe
@@ -267,26 +260,26 @@ foreign import ccall safe
267-- | Any changes to the path (delete, rename, or create) of an object are
260-- | Any changes to the path (delete, rename, or create) of an object are
268-- reported as events for its parent directory. Such events are not reported
261-- reported as events for its parent directory. Such events are not reported
269-- for the watch root itself because its parent is not being watched. When
262-- for the watch root itself because its parent is not being watched. When
270−-- 'setRootPathEvents' is 'On', an 'isRootPathEvent' event is generated with an
263+-- 'setRootPathEvents' is 'True', an 'isRootPathEvent' event is generated with an
271-- eventId 0 if the watch root is deleted, renamed or created.
264-- eventId 0 if the watch root is deleted, renamed or created.
273-- Note: We have observed that an 'isDeleted' event occurs for the root path
266-- Note: We have observed that an 'isDeleted' event occurs for the root path
274-- (when it is a regular dir and not symlink) even when this option is off.
267-- (when it is a regular dir and not symlink) even when this option is off.
276−-- /default: Off/
269+-- /default: False/
278-- /macOS 10.5+/
271-- /macOS 10.5+/
280-- /Pre-release/
273-- /Pre-release/
282−setRootPathEvents :: Switch -> Config -> Config
275+setRootPathEvents :: Bool -> Config -> Config
283setRootPathEvents = setFlag kFSEventStreamCreateFlagWatchRoot
276setRootPathEvents = setFlag kFSEventStreamCreateFlagWatchRoot
285foreign import ccall safe
278foreign import ccall safe
286 "FSEventStreamCreateFlagFileEvents"
279 "FSEventStreamCreateFlagFileEvents"
287 kFSEventStreamCreateFlagFileEvents :: Word32
280 kFSEventStreamCreateFlagFileEvents :: Word32
289−-- | When this is 'Off' only events for the watched directories are reported.
282+-- | When this is 'False' only events for the watched directories are reported.
290-- For example, when a file is created inside a directory it is reported as an
283-- For example, when a file is created inside a directory it is reported as an
291-- event, the path name in the event is the path of the directory being watched
284-- event, the path name in the event is the path of the directory being watched
292-- and not of the specific item for which the event occurred. Events cannot be
285-- and not of the specific item for which the event occurred. Events cannot be
@@ -294,33 +287,33 @@ foreign import ccall safe
294-- if an event is a "create" or "delete", we only know that some event ocurred
287-- if an event is a "create" or "delete", we only know that some event ocurred
295-- under the watched directory hierarchy.
288-- under the watched directory hierarchy.
297−-- When it is 'On' the path reported in the event is the path of the item and
290+-- When it is 'True' the path reported in the event is the path of the item and
298-- not the of the directory in which it is contained. We can use the event
291-- not the of the directory in which it is contained. We can use the event
299-- accessor functions to determine the event type and the path type etc.
292-- accessor functions to determine the event type and the path type etc.
301−-- /default: On/
294+-- /default: True/
303-- /macOS 10.7+/
296-- /macOS 10.7+/
305-- /Pre-release/
298-- /Pre-release/
307−setFileEvents :: Switch -> Config -> Config
300+setFileEvents :: Bool -> Config -> Config
308setFileEvents = setFlag kFSEventStreamCreateFlagFileEvents
301setFileEvents = setFlag kFSEventStreamCreateFlagFileEvents
310foreign import ccall safe
303foreign import ccall safe
311 "FSEventStreamCreateFlagIgnoreSelf"
304 "FSEventStreamCreateFlagIgnoreSelf"
312 kFSEventStreamCreateFlagIgnoreSelf :: Word32
305 kFSEventStreamCreateFlagIgnoreSelf :: Word32
314−-- | When this is 'On' events generated by the current process are not
307+-- | When this is 'True' events generated by the current process are not
315-- reported.
308-- reported.
317−-- /default: Off/
310+-- /default: False/
319-- /macOS 10.6+/
312-- /macOS 10.6+/
321-- /Pre-release/
314-- /Pre-release/
323−setIgnoreSelf :: Switch -> Config -> Config
316+setIgnoreSelf :: Bool -> Config -> Config
324setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf
317setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf
326#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
319#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
@@ -328,26 +321,26 @@ foreign import ccall safe
328 "FSEventStreamCreateFlagFullHistory"
321 "FSEventStreamCreateFlagFullHistory"
329 kFSEventStreamCreateFlagFullHistory :: Word32
322 kFSEventStreamCreateFlagFullHistory :: Word32
331−-- | When this is 'On' all events since the beginning of time are reported.
324+-- | When this is 'True' all events since the beginning of time are reported.
333−-- /default: Off/
326+-- /default: False/
335-- /macOS 10.15+/
328-- /macOS 10.15+/
337-- /Pre-release/
330-- /Pre-release/
339−setFullHistory :: Switch -> Config -> Config
332+setFullHistory :: Bool -> Config -> Config
340setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory
333setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory
343−-- | Set all tunable events 'On' or 'Off'. Equivalent to setting:
336+-- | Set all tunable events 'True' or 'False'. Equivalent to setting:
345-- * setRootPathEvents
338-- * setRootPathEvents
346-- * setFileEvents
339-- * setFileEvents
348-- /Pre-release/
341-- /Pre-release/
350−setAllEvents :: Switch -> Config -> Config
343+setAllEvents :: Bool -> Config -> Config
351setAllEvents s =
344setAllEvents s =
352 setRootPathEvents s
345 setRootPathEvents s
353 . setFileEvents s
346 . setFileEvents s
@@ -359,17 +352,17 @@ setAllEvents s =
359-- | The default settings are:
352-- | The default settings are:
361-- * 'setEventBatching' ('Batch' 0.0)
354-- * 'setEventBatching' ('Batch' 0.0)
362−-- * 'setFileEvents' 'On'
355+-- * 'setFileEvents' 'True'
363−-- * 'setRootPathEvents' 'Off'
356+-- * 'setRootPathEvents' 'False'
364−-- * 'setIgnoreSelf' 'Off'
357+-- * 'setIgnoreSelf' 'False'
365#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
358#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY
366−-- * 'setFullHistory' 'Off'
359+-- * 'setFullHistory' 'False'
369-- /Pre-release/
362-- /Pre-release/
371defaultConfig :: Config
364defaultConfig :: Config
372−defaultConfig = setFileEvents On $ Config
365+defaultConfig = setFileEvents True $ Config
373 { latency = 0.0
366 { latency = 0.0
374 , createFlags = 0
367 , createFlags = 0
@@ -559,7 +552,7 @@ watchToStream (Watch handle _ _) =
560-- {-\# LANGUAGE MagicHash #-}
553-- {-\# LANGUAGE MagicHash #-}
561-- watchWith
554-- watchWith
562−-- ('setIgnoreSelf' 'On' . 'setRootPathEvents' 'On')
555+-- ('setIgnoreSelf' 'True' . 'setRootPathEvents' 'True')
563-- [Array.fromList "path"]
556-- [Array.fromList "path"]
@@ -719,7 +712,7 @@ foreign import ccall safe
719-- object itself. Note that the object may become unreachable or deleted after
712-- object itself. Note that the object may become unreachable or deleted after
720-- a change of path.
713-- a change of path.
722−-- /Applicable only when 'setRootPathEvents' is 'On'/
715+-- /Applicable only when 'setRootPathEvents' is 'True'/
724-- /Occurs only for the watched path/
717-- /Occurs only for the watched path/
@@ -763,7 +756,7 @@ isUnmounted :: Event -> Bool
763isUnmounted = getFlag kFSEventStreamEventFlagUnmount
756isUnmounted = getFlag kFSEventStreamEventFlagUnmount
765-------------------------------------------------------------------------------
758-------------------------------------------------------------------------------
766−-- Metadata change Events (applicable only when 'setFileEvents' is 'On')
759+-- Metadata change Events (applicable only when 'setFileEvents' is 'True')
767-------------------------------------------------------------------------------
760-------------------------------------------------------------------------------
769foreign import ccall safe
762foreign import ccall safe
@@ -776,7 +769,7 @@ foreign import ccall safe
776-- Note that this event may be generated even if the metadata is changed to the
769-- Note that this event may be generated even if the metadata is changed to the
777-- same value again.
770-- same value again.
779−-- /Applicable only when 'setFileEvents' is 'On'/
772+-- /Applicable only when 'setFileEvents' is 'True'/
781-- /Can occur for watched path or a file inside it/
774-- /Can occur for watched path or a file inside it/
@@ -797,7 +790,7 @@ foreign import ccall safe
797-- modification time. It does not occur when the link count of a file changes
790-- modification time. It does not occur when the link count of a file changes
798-- (as of macOS 10.15.1).
791-- (as of macOS 10.15.1).
800−-- /Applicable only when 'setFileEvents' is 'On'/
793+-- /Applicable only when 'setFileEvents' is 'True'/
802-- /Can occur for watched path or a file inside it/
795-- /Can occur for watched path or a file inside it/
@@ -815,7 +808,7 @@ foreign import ccall safe
815-- | Determine whether the event indicates finder information metadata change
808-- | Determine whether the event indicates finder information metadata change
816-- for an object contained within the monitored path.
809-- for an object contained within the monitored path.
818−-- /Applicable only when 'setFileEvents' is 'On'/
811+-- /Applicable only when 'setFileEvents' is 'True'/
820-- /macOS 10.7+/
813-- /macOS 10.7+/
@@ -831,7 +824,7 @@ foreign import ccall safe
831-- | Determine whether the event indicates extended attributes metadata change
824-- | Determine whether the event indicates extended attributes metadata change
832-- for an object contained within the monitored path.
825-- for an object contained within the monitored path.
834−-- /Applicable only when 'setFileEvents' is 'On'/
827+-- /Applicable only when 'setFileEvents' is 'True'/
836-- /Can occur for watched path or a file inside it/
829-- /Can occur for watched path or a file inside it/
@@ -843,7 +836,7 @@ isXAttrsModified :: Event -> Bool
843isXAttrsModified = getFlag kFSEventStreamEventFlagItemXattrMod
836isXAttrsModified = getFlag kFSEventStreamEventFlagItemXattrMod
845-------------------------------------------------------------------------------
838-------------------------------------------------------------------------------
846−-- CRUD Events (applicable only when 'setFileEvents' is 'On')
839+-- CRUD Events (applicable only when 'setFileEvents' is 'True')
847-------------------------------------------------------------------------------
840-------------------------------------------------------------------------------
849foreign import ccall safe
842foreign import ccall safe
@@ -865,7 +858,7 @@ foreign import ccall safe
865-- only an 'isAttrsModified' event occurs and there is no 'isCreated'
858-- only an 'isAttrsModified' event occurs and there is no 'isCreated'
866-- event. However, this seems to have been fixed on 10.15.6.
859-- event. However, this seems to have been fixed on 10.15.6.
868−-- /Applicable only when 'setFileEvents' is 'On'/
861+-- /Applicable only when 'setFileEvents' is 'True'/
870-- /Can occur for watched path or a file inside it/
863-- /Can occur for watched path or a file inside it/
@@ -883,7 +876,7 @@ foreign import ccall safe
883-- | Determine whether the event indicates deletion of an object within the
876-- | Determine whether the event indicates deletion of an object within the
884-- monitored path. This is true when a file or a hardlink is deleted.
877-- monitored path. This is true when a file or a hardlink is deleted.
886−-- Applicable only when 'setFileEvents' is 'On'.
879+-- Applicable only when 'setFileEvents' is 'True'.
888-- /Can occur for watched path or a file inside it/
881-- /Can occur for watched path or a file inside it/
@@ -902,7 +895,7 @@ foreign import ccall safe
902-- monitored path. This event is generated when a file is renamed within the
895-- monitored path. This event is generated when a file is renamed within the
903-- watched directory or if it is moved out of or in the watched directory.
896-- watched directory or if it is moved out of or in the watched directory.
905−-- /Applicable only when 'setFileEvents' is 'On'/
898+-- /Applicable only when 'setFileEvents' is 'True'/
907-- /Can occur for watched path or a file inside it/
900-- /Can occur for watched path or a file inside it/
@@ -920,7 +913,7 @@ foreign import ccall safe
920-- | Determine whether the event indicates modification of an object within the
913-- | Determine whether the event indicates modification of an object within the
921-- monitored path. This event is generated only for files and not directories.
914-- monitored path. This event is generated only for files and not directories.
923−-- Applicable only when 'setFileEvents' is 'On'.
916+-- Applicable only when 'setFileEvents' is 'True'.
925-- /macOS 10.7+/
918-- /macOS 10.7+/
@@ -938,7 +931,7 @@ foreign import ccall safe
938-- monitored path. The "Duplicate" command in the "File" menu of the "Finder"
931-- monitored path. The "Duplicate" command in the "File" menu of the "Finder"
939-- application generates a "clone" event.
932-- application generates a "clone" event.
941−-- Applicable only when 'setFileEvents' is 'On'.
934+-- Applicable only when 'setFileEvents' is 'True'.
943-- /macOS 10.13+/
936-- /macOS 10.13+/
@@ -949,7 +942,7 @@ isCloned = getFlag kFSEventStreamEventFlagItemCloned
951-------------------------------------------------------------------------------
944-------------------------------------------------------------------------------
952−-- Information about path type (applicable only when 'setFileEvents' is 'On')
945+-- Information about path type (applicable only when 'setFileEvents' is 'True')
953-------------------------------------------------------------------------------
946-------------------------------------------------------------------------------
955foreign import ccall safe
948foreign import ccall safe
@@ -958,7 +951,7 @@ foreign import ccall safe
959-- | Determine whether the event is for a directory path.
952-- | Determine whether the event is for a directory path.
961−-- Applicable only when 'setFileEvents' is 'On'.
954+-- Applicable only when 'setFileEvents' is 'True'.
963-- /macOS 10.7+/
956-- /macOS 10.7+/
@@ -973,7 +966,7 @@ foreign import ccall safe
974-- | Determine whether the event is for a file path.
967-- | Determine whether the event is for a file path.
976−-- Applicable only when 'setFileEvents' is 'On'.
969+-- Applicable only when 'setFileEvents' is 'True'.
978-- /macOS 10.7+/
971-- /macOS 10.7+/
@@ -988,7 +981,7 @@ foreign import ccall safe
989-- | Determine whether the event is for a symbolic link path.
982-- | Determine whether the event is for a symbolic link path.
991−-- Applicable only when 'setFileEvents' is 'On'.
984+-- Applicable only when 'setFileEvents' is 'True'.
993-- /macOS 10.7+/
986-- /macOS 10.7+/
@@ -1008,7 +1001,7 @@ foreign import ccall safe
1008-- which has or had more than one link in the past is removed. This is not true
1001-- which has or had more than one link in the past is removed. This is not true
1009-- if a file never had more than one link.
1002-- if a file never had more than one link.
1011−-- Applicable only when 'setFileEvents' is 'On'.
1004+-- Applicable only when 'setFileEvents' is 'True'.
1013-- /macOS 10.10+/
1006-- /macOS 10.10+/
@@ -1026,7 +1019,7 @@ foreign import ccall safe
1026-- is true when a file has had more than one link and now the last link is
1019-- is true when a file has had more than one link and now the last link is
1027-- removed. In that case both 'isHardLink' and 'isLastHardLink" would be true.
1020-- removed. In that case both 'isHardLink' and 'isLastHardLink" would be true.
1029−-- Applicable only when 'setFileEvents' is 'On'.
1022+-- Applicable only when 'setFileEvents' is 'True'.
1031-- /macOS 10.10+/
1024-- /macOS 10.10+/