示例#1
0
 public WatchInternal(InotifyCallback callback, EventType mask, WatchInfo watchinfo)
 {
     this.callback      = callback;
     this.mask          = mask;
     this.watchinfo     = watchinfo;
     this.is_subscribed = true;
 }
示例#2
0
        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);
        }
示例#3
0
 public static Watch Subscribe(string path, InotifyCallback callback, EventType mask)
 {
     return(Subscribe(path, callback, mask, 0));
 }
示例#4
0
		public static Watch Subscribe (string path, InotifyCallback callback, EventType mask)
		{
			return Subscribe (path, callback, mask, 0);
		}
示例#5
0
		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;
		}
示例#6
0
			public WatchInternal (InotifyCallback callback, EventType mask, WatchInfo watchinfo)
			{
				this.callback = callback;
				this.mask = mask;
				this.watchinfo = watchinfo;
				this.is_subscribed = true;
			}