public static Watch Subscribe(string path, InotifyCallback callback, EventType mask, EventType initial_filter) { WatchInternal watch; WatchInfo watched; EventType mask_orig = mask; if (!Path.IsPathRooted(path)) { path = Path.GetFullPath(path); } bool is_directory = false; if (Directory.Exists(path)) { is_directory = true; } else if (!File.Exists(path)) { throw new IOException(path); } lock (watched_by_wd) { watched = watched_by_path [path] as WatchInfo; if (watched == null) { // We need an entirely new WatchInfo object watched = new WatchInfo(); watched.Path = path; watched.IsDirectory = is_directory; watched.Subscribers = new ArrayList(); watched.Children = new ArrayList(); DirectoryInfo dir = new DirectoryInfo(path); if (dir.Parent != null) { watched.Parent = watched_by_path [dir.Parent.ToString()] as WatchInfo; } if (watched.Parent != null) { watched.Parent.Children.Add(watched); } watched_by_path [watched.Path] = watched; } watched.FilterMask = initial_filter; watched.FilterSeen = 0; watch = new WatchInternal(callback, mask_orig, watched); watched.Subscribers.Add(watch); CreateOrModifyWatch(watched); watched_by_wd [watched.Wd] = watched; } return(watch); }
static private void Unsubscribe(WatchInfo watched, WatchInternal watch) { watched.Subscribers.Remove(watch); // Other subscribers might still be around if (watched.Subscribers.Count > 0) { // Minimize it CreateOrModifyWatch(watched); return; } int retval = inotify_glue_ignore(inotify_fd, watched.Wd); if (retval < 0) { string msg = String.Format("Attempt to ignore {0} failed!", watched.Path); throw new IOException(msg); } Forget(watched); return; }
private static void Unsubscribe(WatchInfo watched, WatchInternal watch) { watched.Subscribers.Remove(watch); // Other subscribers might still be around if (watched.Subscribers.Count > 0) { // Minimize it CreateOrModifyWatch(watched); return; } int retval = inotify_glue_ignore(inotify_fd, watched.Wd); if (retval < 0) { Mono.Unix.Native.Errno errno = Mono.Unix.Native.NativeConvert.ToErrno(-retval); string msg = String.Format("Attempt to ignore {0} failed: {1}", watched.Path, Mono.Unix.UnixMarshal.GetErrorDescription(errno)); throw new IOException(msg); } Forget(watched); return; }
private static void Unsubscribe (WatchInfo watched, WatchInternal watch) { watched.Subscribers.Remove (watch); // Other subscribers might still be around if (watched.Subscribers.Count > 0) { // Minimize it CreateOrModifyWatch (watched); return; } int retval = inotify_glue_ignore (inotify_fd, watched.Wd); if (retval < 0) { Mono.Unix.Native.Errno errno = Mono.Unix.Native.NativeConvert.ToErrno (-retval); string msg = String.Format ("Attempt to ignore {0} failed: {1}", watched.Path, Mono.Unix.UnixMarshal.GetErrorDescription (errno)); throw new IOException (msg); } Forget (watched); return; }
public static Watch Subscribe (string path, InotifyCallback callback, EventType mask, EventType initial_filter) { WatchInternal watch; WatchInfo watched; EventType mask_orig = mask; if (!Path.IsPathRooted (path)) path = Path.GetFullPath (path); bool is_directory = false; if (Directory.Exists (path)) is_directory = true; else if (! File.Exists (path)) throw new IOException (path); lock (watched_by_wd) { watched = watched_by_path [path] as WatchInfo; if (watched == null) { // We need an entirely new WatchInfo object watched = new WatchInfo (); watched.Path = path; watched.IsDirectory = is_directory; watched.Subscribers = new ArrayList (); watched.Children = new ArrayList (); DirectoryInfo dir = new DirectoryInfo (path); if (dir.Parent != null) watched.Parent = watched_by_path [dir.Parent.ToString ()] as WatchInfo; if (watched.Parent != null) watched.Parent.Children.Add (watched); watched_by_path [watched.Path] = watched; } watched.FilterMask = initial_filter; watched.FilterSeen = 0; watch = new WatchInternal (callback, mask_orig, watched); watched.Subscribers.Add (watch); CreateOrModifyWatch (watched); watched_by_wd [watched.Wd] = watched; } return watch; }
private static void Unsubscribe(WatchInfo watched, WatchInternal watch) { watched.Subscribers.Remove (watch); // Other subscribers might still be around if (watched.Subscribers.Count > 0) { // Minimize it CreateOrModifyWatch (watched); return; } int retval = inotify_glue_ignore (inotify_fd, watched.Wd); if (retval < 0) { string msg = String.Format ("Attempt to ignore {0} failed!", watched.Path); throw new IOException (msg); } Forget (watched); return; }