+ Hashtbl.add masks dir (wd,handler);
+ Hashtbl.add wdmap wd (dir,Some(handler))
+
+ (* Ignore the possibility that the whole directory can disappear and come
+ * back while it is masked *)
+
+let mask_watch dir =
+ try
+ let wd,_ = Hashtbl.find masks dir in
+ Inotify.rm_watch fd wd;
+ Hashtbl.remove wdmap wd
+ with _ ->
+ ()
+
+let unmask_watch dir events =
+ let _,handler = try Hashtbl.find masks dir with Not_found->fprintf logfd "unmask called without mask: %s\n" dir;flush logfd;raise Not_found in
+ try
+ Hashtbl.remove masks dir;
+ add_watch dir events handler
+ with Not_found -> ()