Пример #1
0
 private static void StopMonitoringDirectory(FAMData data)
 {
     if (FAMWatcher.FAMCancelMonitor(ref FAMWatcher.conn, ref data.Request) == -1)
     {
         throw new System.ComponentModel.Win32Exception();
     }
 }
Пример #2
0
        private static void StartMonitoringDirectory(FAMData data, bool justcreated)
        {
            FAMRequest request;

            if (FAMWatcher.FAMMonitorDirectory(ref FAMWatcher.conn, data.Directory, out request, IntPtr.Zero) == -1)
            {
                throw new System.ComponentModel.Win32Exception();
            }
            FileSystemWatcher fsw = data.FSW;

            data.Request = request;
            if (data.IncludeSubdirs)
            {
                foreach (string text in Directory.GetDirectories(data.Directory))
                {
                    FAMData famdata = new FAMData();
                    famdata.FSW            = data.FSW;
                    famdata.Directory      = text;
                    famdata.FileMask       = data.FSW.MangledFilter;
                    famdata.IncludeSubdirs = true;
                    famdata.SubDirs        = new Hashtable();
                    famdata.Enabled        = true;
                    if (justcreated)
                    {
                        FileSystemWatcher obj = fsw;
                        lock (obj)
                        {
                            RenamedEventArgs renamedEventArgs = null;
                            fsw.DispatchEvents(FileAction.Added, text, ref renamedEventArgs);
                            if (fsw.Waiting)
                            {
                                fsw.Waiting = false;
                                System.Threading.Monitor.PulseAll(fsw);
                            }
                        }
                    }
                    FAMWatcher.StartMonitoringDirectory(famdata, justcreated);
                    data.SubDirs[text] = famdata;
                    FAMWatcher.requests[famdata.Request.ReqNum] = famdata;
                }
            }
            if (justcreated)
            {
                foreach (string filename in Directory.GetFiles(data.Directory))
                {
                    FileSystemWatcher obj2 = fsw;
                    lock (obj2)
                    {
                        RenamedEventArgs renamedEventArgs2 = null;
                        fsw.DispatchEvents(FileAction.Added, filename, ref renamedEventArgs2);
                        fsw.DispatchEvents(FileAction.Modified, filename, ref renamedEventArgs2);
                        if (fsw.Waiting)
                        {
                            fsw.Waiting = false;
                            System.Threading.Monitor.PulseAll(fsw);
                        }
                    }
                }
            }
        }
Пример #3
0
        public void StartDispatching(FileSystemWatcher fsw)
        {
            FAMData famdata;

            lock (this)
            {
                if (FAMWatcher.thread == null)
                {
                    FAMWatcher.thread = new Thread(new ThreadStart(this.Monitor));
                    FAMWatcher.thread.IsBackground = true;
                    FAMWatcher.thread.Start();
                }
                famdata = (FAMData)FAMWatcher.watches[fsw];
            }
            if (famdata == null)
            {
                famdata                = new FAMData();
                famdata.FSW            = fsw;
                famdata.Directory      = fsw.FullPath;
                famdata.FileMask       = fsw.MangledFilter;
                famdata.IncludeSubdirs = fsw.IncludeSubdirectories;
                if (famdata.IncludeSubdirs)
                {
                    famdata.SubDirs = new Hashtable();
                }
                famdata.Enabled = true;
                FAMWatcher.StartMonitoringDirectory(famdata, false);
                lock (this)
                {
                    FAMWatcher.watches[fsw] = famdata;
                    FAMWatcher.requests[famdata.Request.ReqNum] = famdata;
                    FAMWatcher.stop = false;
                }
            }
        }
Пример #4
0
 static void StopMonitoringDirectory(FAMData data)
 {
     if (FAMCancelMonitor(ref conn, ref data.Request) == -1)
     {
         throw new Win32Exception();
     }
 }
Пример #5
0
        public void StartDispatching(FileSystemWatcher fsw)
        {
            FAMData fAMData;

            lock (this)
            {
                if (thread == null)
                {
                    thread = new Thread(Monitor);
                    thread.IsBackground = true;
                    thread.Start();
                }
                fAMData = (FAMData)watches[fsw];
            }
            if (fAMData == null)
            {
                fAMData                = new FAMData();
                fAMData.FSW            = fsw;
                fAMData.Directory      = fsw.FullPath;
                fAMData.FileMask       = fsw.MangledFilter;
                fAMData.IncludeSubdirs = fsw.IncludeSubdirectories;
                if (fAMData.IncludeSubdirs)
                {
                    fAMData.SubDirs = new Hashtable();
                }
                fAMData.Enabled = true;
                StartMonitoringDirectory(fAMData, justcreated: false);
                lock (this)
                {
                    watches[fsw] = fAMData;
                    requests[fAMData.Request.ReqNum] = fAMData;
                    stop = false;
                }
            }
        }
Пример #6
0
 public void StopDispatching(FileSystemWatcher fsw)
 {
     lock (this)
     {
         FAMData famdata = (FAMData)FAMWatcher.watches[fsw];
         if (famdata != null)
         {
             FAMWatcher.StopMonitoringDirectory(famdata);
             FAMWatcher.watches.Remove(fsw);
             FAMWatcher.requests.Remove(famdata.Request.ReqNum);
             if (FAMWatcher.watches.Count == 0)
             {
                 FAMWatcher.stop = true;
             }
             if (famdata.IncludeSubdirs)
             {
                 foreach (object obj in famdata.SubDirs.Values)
                 {
                     FAMData famdata2 = (FAMData)obj;
                     FAMWatcher.StopMonitoringDirectory(famdata2);
                     FAMWatcher.requests.Remove(famdata2.Request.ReqNum);
                 }
             }
         }
     }
 }
Пример #7
0
 public void StopDispatching(FileSystemWatcher fsw)
 {
     lock (this)
     {
         FAMData fAMData = (FAMData)watches[fsw];
         if (fAMData != null)
         {
             StopMonitoringDirectory(fAMData);
             watches.Remove(fsw);
             requests.Remove(fAMData.Request.ReqNum);
             if (watches.Count == 0)
             {
                 stop = true;
             }
             if (fAMData.IncludeSubdirs)
             {
                 foreach (FAMData value in fAMData.SubDirs.Values)
                 {
                     StopMonitoringDirectory(value);
                     requests.Remove(value.Request.ReqNum);
                 }
             }
         }
     }
 }
Пример #8
0
        private static void StartMonitoringDirectory(FAMData data, bool justcreated)
        {
            if (FAMMonitorDirectory(ref conn, data.Directory, out FAMRequest fr, IntPtr.Zero) == -1)
            {
                throw new Win32Exception();
            }
            FileSystemWatcher fSW = data.FSW;

            data.Request = fr;
            if (data.IncludeSubdirs)
            {
                string[] directories = Directory.GetDirectories(data.Directory);
                foreach (string text in directories)
                {
                    FAMData fAMData = new FAMData();
                    fAMData.FSW            = data.FSW;
                    fAMData.Directory      = text;
                    fAMData.FileMask       = data.FSW.MangledFilter;
                    fAMData.IncludeSubdirs = true;
                    fAMData.SubDirs        = new Hashtable();
                    fAMData.Enabled        = true;
                    if (justcreated)
                    {
                        lock (fSW)
                        {
                            RenamedEventArgs renamed = null;
                            fSW.DispatchEvents(FileAction.Added, text, ref renamed);
                            if (fSW.Waiting)
                            {
                                fSW.Waiting = false;
                                System.Threading.Monitor.PulseAll(fSW);
                            }
                        }
                    }
                    StartMonitoringDirectory(fAMData, justcreated);
                    data.SubDirs[text] = fAMData;
                    requests[fAMData.Request.ReqNum] = fAMData;
                }
            }
            if (justcreated)
            {
                string[] files = Directory.GetFiles(data.Directory);
                foreach (string filename in files)
                {
                    lock (fSW)
                    {
                        RenamedEventArgs renamed2 = null;
                        fSW.DispatchEvents(FileAction.Added, filename, ref renamed2);
                        fSW.DispatchEvents(FileAction.Modified, filename, ref renamed2);
                        if (fSW.Waiting)
                        {
                            fSW.Waiting = false;
                            System.Threading.Monitor.PulseAll(fSW);
                        }
                    }
                }
            }
        }
Пример #9
0
        public void StartDispatching(object handle)
        {
            var     fsw = handle as FileSystemWatcher;
            FAMData data;

            lock (this) {
                if (thread == null)
                {
                    thread = new Thread(new ThreadStart(Monitor));
                    thread.IsBackground = true;
                    thread.Start();
                }

                data = (FAMData)watches [fsw];
            }

            if (data == null)
            {
                data                = new FAMData();
                data.FSW            = fsw;
                data.Directory      = fsw.FullPath;
                data.FileMask       = fsw.MangledFilter;
                data.IncludeSubdirs = fsw.IncludeSubdirectories;
                if (data.IncludeSubdirs)
                {
                    data.SubDirs = new Hashtable();
                }

                data.Enabled = true;
                StartMonitoringDirectory(data, false);
                lock (this) {
                    watches [fsw] = data;
                    requests [data.Request.ReqNum] = data;
                    stop = false;
                }
            }
        }
Пример #10
0
        void ProcessEvents()
        {
            ArrayList newdirs = null;

            lock (this)
            {
                do
                {
                    int               code;
                    string            filename;
                    int               requestNumber;
                    FileSystemWatcher fsw;

                    if (InternalFAMNextEvent(ref conn, out filename,
                                             out code, out requestNumber) != 1)
                    {
                        return;
                    }

                    bool found = false;
                    switch ((FAMCodes)code)
                    {
                    case FAMCodes.Changed:
                    case FAMCodes.Deleted:
                    case FAMCodes.Created:
                        found = requests.ContainsKey(requestNumber);
                        break;

                    case FAMCodes.Moved:
                    case FAMCodes.StartExecuting:
                    case FAMCodes.StopExecuting:
                    case FAMCodes.Acknowledge:
                    case FAMCodes.Exists:
                    case FAMCodes.EndExist:
                    default:
                        found = false;
                        break;
                    }

                    if (!found)
                    {
                        continue;
                    }

                    FAMData data = (FAMData)requests [requestNumber];
                    if (!data.Enabled)
                    {
                        continue;
                    }

                    fsw = data.FSW;
                    NotifyFilters    flt     = fsw.NotifyFilter;
                    RenamedEventArgs renamed = null;
                    FileAction       fa      = 0;
                    if (code == (int)FAMCodes.Changed && (flt & changed) != 0)
                    {
                        fa = FileAction.Modified;
                    }
                    else if (code == (int)FAMCodes.Deleted)
                    {
                        fa = FileAction.Removed;
                    }
                    else if (code == (int)FAMCodes.Created)
                    {
                        fa = FileAction.Added;
                    }

                    if (fa == 0)
                    {
                        continue;
                    }

                    if (fsw.IncludeSubdirectories)
                    {
                        string full    = fsw.FullPath;
                        string datadir = data.Directory;
                        if (datadir != full)
                        {
                            int len   = full.Length;
                            int slash = 1;
                            if (len > 1 && full [len - 1] == Path.DirectorySeparatorChar)
                            {
                                slash = 0;
                            }
                            string reldir = datadir.Substring(full.Length + slash);
                            datadir  = Path.Combine(datadir, filename);
                            filename = Path.Combine(reldir, filename);
                        }
                        else
                        {
                            datadir = Path.Combine(full, filename);
                        }

                        if (fa == FileAction.Added && Directory.Exists(datadir))
                        {
                            if (newdirs == null)
                            {
                                newdirs = new ArrayList(4);
                            }

                            FAMData fd = new FAMData();
                            fd.FSW            = fsw;
                            fd.Directory      = datadir;
                            fd.FileMask       = fsw.MangledFilter;
                            fd.IncludeSubdirs = true;
                            fd.SubDirs        = new Hashtable();
                            fd.Enabled        = true;
                            newdirs.Add(fd);
                            newdirs.Add(data);
                        }
                    }

                    if (filename != data.Directory && !fsw.Pattern.IsMatch(filename))
                    {
                        continue;
                    }

                    lock (fsw)
                    {
                        fsw.DispatchEvents(fa, filename, ref renamed);
                        if (fsw.Waiting)
                        {
                            fsw.Waiting = false;
                            System.Threading.Monitor.PulseAll(fsw);
                        }
                    }
                }while (FAMPending(ref conn) > 0);
            }


            if (newdirs != null)
            {
                int count = newdirs.Count;
                for (int n = 0; n < count; n += 2)
                {
                    FAMData newdir = (FAMData)newdirs [n];
                    FAMData parent = (FAMData)newdirs [n + 1];
                    StartMonitoringDirectory(newdir, true);
                    requests [newdir.Request.ReqNum] = newdir;
                    lock (parent)
                    {
                        parent.SubDirs [newdir.Directory] = newdir;
                    }
                }
                newdirs.Clear();
            }
        }
Пример #11
0
        static void StartMonitoringDirectory(FAMData data, bool justcreated)
        {
            FAMRequest        fr;
            FileSystemWatcher fsw;

            if (FAMMonitorDirectory(ref conn, data.Directory, out fr, IntPtr.Zero) == -1)
            {
                throw new Win32Exception();
            }

            fsw          = data.FSW;
            data.Request = fr;

            if (data.IncludeSubdirs)
            {
                foreach (string directory in Directory.GetDirectories(data.Directory))
                {
                    FAMData fd = new FAMData();
                    fd.FSW            = data.FSW;
                    fd.Directory      = directory;
                    fd.FileMask       = data.FSW.MangledFilter;
                    fd.IncludeSubdirs = true;
                    fd.SubDirs        = new Hashtable();
                    fd.Enabled        = true;

                    if (justcreated)
                    {
                        lock (fsw)
                        {
                            RenamedEventArgs renamed = null;

                            fsw.DispatchEvents(FileAction.Added, directory, ref renamed);

                            if (fsw.Waiting)
                            {
                                fsw.Waiting = false;
                                System.Threading.Monitor.PulseAll(fsw);
                            }
                        }
                    }

                    StartMonitoringDirectory(fd, justcreated);
                    data.SubDirs [directory]     = fd;
                    requests [fd.Request.ReqNum] = fd;
                }
            }

            if (justcreated)
            {
                foreach (string filename in Directory.GetFiles(data.Directory))
                {
                    lock (fsw)
                    {
                        RenamedEventArgs renamed = null;

                        fsw.DispatchEvents(FileAction.Added, filename, ref renamed);
                        /* If a file has been created, then it has been written to */
                        fsw.DispatchEvents(FileAction.Modified, filename, ref renamed);

                        if (fsw.Waiting)
                        {
                            fsw.Waiting = false;
                            System.Threading.Monitor.PulseAll(fsw);
                        }
                    }
                }
            }
        }
Пример #12
0
		public void StartDispatching (FileSystemWatcher fsw)
		{
			FAMData data;
			lock (this) {
				if (thread == null) {
					thread = new Thread (new ThreadStart (Monitor));
					thread.IsBackground = true;
					thread.Start ();
				}

				data = (FAMData) watches [fsw];
			}

			if (data == null) {
				data = new FAMData ();
				data.FSW = fsw;
				data.Directory = fsw.FullPath;
				data.FileMask = fsw.MangledFilter;
				data.IncludeSubdirs = fsw.IncludeSubdirectories;
				if (data.IncludeSubdirs)
					data.SubDirs = new Hashtable ();

				data.Enabled = true;
				StartMonitoringDirectory (data, false);
				lock (this) {
					watches [fsw] = data;
					requests [data.Request.ReqNum] = data;
					stop = false;
				}
			}
		}
Пример #13
0
		static void StartMonitoringDirectory (FAMData data, bool justcreated)
		{
			FAMRequest fr;
			FileSystemWatcher fsw;
			if (FAMMonitorDirectory (ref conn, data.Directory, out fr, IntPtr.Zero) == -1)
				throw new Win32Exception ();

			fsw = data.FSW;
			data.Request = fr;

			if (data.IncludeSubdirs) {
				foreach (string directory in Directory.GetDirectories (data.Directory)) {
					FAMData fd = new FAMData ();
					fd.FSW = data.FSW;
					fd.Directory = directory;
					fd.FileMask = data.FSW.MangledFilter;
					fd.IncludeSubdirs = true;
					fd.SubDirs = new Hashtable ();
					fd.Enabled = true;

					if (justcreated) {
						lock (fsw) {
							RenamedEventArgs renamed = null;

							fsw.DispatchEvents (FileAction.Added, directory, ref renamed);

							if (fsw.Waiting) {
								fsw.Waiting = false;
								System.Threading.Monitor.PulseAll (fsw);
							}
						}
					}

					StartMonitoringDirectory (fd, justcreated);
					data.SubDirs [directory] = fd;
					requests [fd.Request.ReqNum] = fd;
				}
			}

			if (justcreated) {
				foreach (string filename in Directory.GetFiles(data.Directory)) {
					lock (fsw) {
						RenamedEventArgs renamed = null;

						fsw.DispatchEvents (FileAction.Added, filename, ref renamed);
						/* If a file has been created, then it has been written to */
						fsw.DispatchEvents (FileAction.Modified, filename, ref renamed);

						if (fsw.Waiting) {
							fsw.Waiting = false;
							System.Threading.Monitor.PulseAll(fsw);
						}
					}
				}
			}
		}
Пример #14
0
		static void StopMonitoringDirectory (FAMData data)
		{
			if (FAMCancelMonitor (ref conn, ref data.Request) == -1)
				throw new Win32Exception ();
		}
Пример #15
0
        private void ProcessEvents()
        {
            ArrayList arrayList = null;

            lock (this)
            {
                string text;
                int    num;
                int    num2;
                while (FAMWatcher.InternalFAMNextEvent(ref FAMWatcher.conn, out text, out num, out num2) == 1)
                {
                    bool flag;
                    switch (num)
                    {
                    case 1:
                    case 2:
                    case 5:
                        flag = FAMWatcher.requests.ContainsKey(num2);
                        break;

                    case 3:
                    case 4:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        goto IL_75;

                    default:
                        goto IL_75;
                    }
IL_7D:
                    if (flag)
                    {
                        FAMData famdata = (FAMData)FAMWatcher.requests[num2];
                        if (famdata.Enabled)
                        {
                            FileSystemWatcher fsw              = famdata.FSW;
                            NotifyFilters     notifyFilter     = fsw.NotifyFilter;
                            RenamedEventArgs  renamedEventArgs = null;
                            FileAction        fileAction       = (FileAction)0;
                            if (num == 1 && (notifyFilter & (NotifyFilters.Attributes | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Size)) != (NotifyFilters)0)
                            {
                                fileAction = FileAction.Modified;
                            }
                            else if (num == 2)
                            {
                                fileAction = FileAction.Removed;
                            }
                            else if (num == 5)
                            {
                                fileAction = FileAction.Added;
                            }
                            if (fileAction != (FileAction)0)
                            {
                                if (fsw.IncludeSubdirectories)
                                {
                                    string fullPath = fsw.FullPath;
                                    string text2    = famdata.Directory;
                                    if (text2 != fullPath)
                                    {
                                        int length = fullPath.Length;
                                        int num3   = 1;
                                        if (length > 1 && fullPath[length - 1] == Path.DirectorySeparatorChar)
                                        {
                                            num3 = 0;
                                        }
                                        string path = text2.Substring(fullPath.Length + num3);
                                        text2 = Path.Combine(text2, text);
                                        text  = Path.Combine(path, text);
                                    }
                                    else
                                    {
                                        text2 = Path.Combine(fullPath, text);
                                    }
                                    if (fileAction == FileAction.Added && Directory.Exists(text2))
                                    {
                                        if (arrayList == null)
                                        {
                                            arrayList = new ArrayList(4);
                                        }
                                        arrayList.Add(new FAMData
                                        {
                                            FSW            = fsw,
                                            Directory      = text2,
                                            FileMask       = fsw.MangledFilter,
                                            IncludeSubdirs = true,
                                            SubDirs        = new Hashtable(),
                                            Enabled        = true
                                        });
                                        arrayList.Add(famdata);
                                    }
                                }
                                if (!(text != famdata.Directory) || fsw.Pattern.IsMatch(text))
                                {
                                    FileSystemWatcher obj = fsw;
                                    lock (obj)
                                    {
                                        fsw.DispatchEvents(fileAction, text, ref renamedEventArgs);
                                        if (fsw.Waiting)
                                        {
                                            fsw.Waiting = false;
                                            System.Threading.Monitor.PulseAll(fsw);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (FAMWatcher.FAMPending(ref FAMWatcher.conn) <= 0)
                    {
                        goto IL_28F;
                    }
                    continue;
IL_75:
                    flag = false;
                    goto IL_7D;
                }
                return;
            }
IL_28F:
            if (arrayList != null)
            {
                int count = arrayList.Count;
                for (int i = 0; i < count; i += 2)
                {
                    FAMData famdata2 = (FAMData)arrayList[i];
                    FAMData famdata3 = (FAMData)arrayList[i + 1];
                    FAMWatcher.StartMonitoringDirectory(famdata2, true);
                    FAMWatcher.requests[famdata2.Request.ReqNum] = famdata2;
                    FAMData obj2 = famdata3;
                    lock (obj2)
                    {
                        famdata3.SubDirs[famdata2.Directory] = famdata2;
                    }
                }
                arrayList.Clear();
            }
        }
Пример #16
0
		void ProcessEvents ()
		{
			ArrayList newdirs = null;
			lock (this) {
				do {
					int code;
					string filename;
					int requestNumber;
					FileSystemWatcher fsw;

					if (InternalFAMNextEvent (ref conn, out filename,
								  out code, out requestNumber) != 1)
						return;

					bool found = false;
					switch ((FAMCodes) code) {
					case FAMCodes.Changed:
					case FAMCodes.Deleted:
					case FAMCodes.Created:
						found = requests.ContainsKey (requestNumber);
						break;
					case FAMCodes.Moved:
					case FAMCodes.StartExecuting:
					case FAMCodes.StopExecuting:
					case FAMCodes.Acknowledge:
					case FAMCodes.Exists:
					case FAMCodes.EndExist:
					default:
						found = false;
						break;
					}

					if (!found)
						continue;
					
					FAMData data = (FAMData) requests [requestNumber];
					if (!data.Enabled)
						continue;

					fsw = data.FSW;
					NotifyFilters flt = fsw.NotifyFilter;
					RenamedEventArgs renamed = null;
					FileAction fa = 0;
					if (code == (int) FAMCodes.Changed && (flt & changed) != 0)
						fa = FileAction.Modified;
					else if (code == (int) FAMCodes.Deleted)
						fa = FileAction.Removed;
					else if (code == (int) FAMCodes.Created)
						fa = FileAction.Added;

					if (fa == 0)
						continue;

					if (fsw.IncludeSubdirectories) {
						string full = fsw.FullPath;
						string datadir = data.Directory;
						if (datadir != full) {
							int len = full.Length;
							int slash = 1;
							if (len > 1 && full [len - 1] == Path.DirectorySeparatorChar)
								slash = 0;
							string reldir = datadir.Substring (full.Length + slash);
							datadir = Path.Combine (datadir, filename);
							filename = Path.Combine (reldir, filename);
						} else {
							datadir = Path.Combine (full, filename);
						}

						if (fa == FileAction.Added && Directory.Exists (datadir)) {
							if (newdirs == null)
								newdirs = new ArrayList (4);

							FAMData fd = new FAMData ();
							fd.FSW = fsw;
							fd.Directory = datadir;
							fd.FileMask = fsw.MangledFilter;
							fd.IncludeSubdirs = true;
							fd.SubDirs = new Hashtable ();
							fd.Enabled = true;
							newdirs.Add (fd);
							newdirs.Add (data);
						}
					}

					if (filename != data.Directory && !fsw.Pattern.IsMatch (filename))
						continue;

					lock (fsw) {
						fsw.DispatchEvents (fa, filename, ref renamed);
						if (fsw.Waiting) {
							fsw.Waiting = false;
							System.Threading.Monitor.PulseAll (fsw);
						}
					}
				} while (FAMPending (ref conn) > 0);
			}


			if (newdirs != null) {
				int count = newdirs.Count;
				for (int n = 0; n < count; n += 2) {
					FAMData newdir = (FAMData) newdirs [n];
					FAMData parent = (FAMData) newdirs [n + 1];
					StartMonitoringDirectory (newdir, true);
					requests [newdir.Request.ReqNum] = newdir;
					lock (parent) {
						parent.SubDirs [newdir.Directory] = newdir;
					}
				}
				newdirs.Clear ();
			}
		}
Пример #17
0
        private void ProcessEvents()
        {
            ArrayList arrayList = null;

            lock (this)
            {
                do
                {
                    if (InternalFAMNextEvent(ref conn, out string filename, out int code, out int reqnum) != 1)
                    {
                        return;
                    }
                    bool flag = false;
                    switch (code)
                    {
                    case 1:
                    case 2:
                    case 5:
                        flag = requests.ContainsKey(reqnum);
                        break;

                    default:
                        flag = false;
                        break;
                    }
                    if (flag)
                    {
                        FAMData fAMData = (FAMData)requests[reqnum];
                        if (fAMData.Enabled)
                        {
                            FileSystemWatcher fSW          = fAMData.FSW;
                            NotifyFilters     notifyFilter = fSW.NotifyFilter;
                            RenamedEventArgs  renamed      = null;
                            FileAction        fileAction   = (FileAction)0;
                            if (code == 1 && (notifyFilter & (NotifyFilters.Attributes | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Size)) != 0)
                            {
                                fileAction = FileAction.Modified;
                            }
                            else
                            {
                                switch (code)
                                {
                                case 2:
                                    fileAction = FileAction.Removed;
                                    break;

                                case 5:
                                    fileAction = FileAction.Added;
                                    break;
                                }
                            }
                            if (fileAction != 0)
                            {
                                if (fSW.IncludeSubdirectories)
                                {
                                    string fullPath  = fSW.FullPath;
                                    string directory = fAMData.Directory;
                                    if (directory != fullPath)
                                    {
                                        int length = fullPath.Length;
                                        int num    = 1;
                                        if (length > 1 && fullPath[length - 1] == Path.DirectorySeparatorChar)
                                        {
                                            num = 0;
                                        }
                                        string path = directory.Substring(fullPath.Length + num);
                                        directory = Path.Combine(directory, filename);
                                        filename  = Path.Combine(path, filename);
                                    }
                                    else
                                    {
                                        directory = Path.Combine(fullPath, filename);
                                    }
                                    if (fileAction == FileAction.Added && Directory.Exists(directory))
                                    {
                                        if (arrayList == null)
                                        {
                                            arrayList = new ArrayList(4);
                                        }
                                        FAMData fAMData2 = new FAMData();
                                        fAMData2.FSW            = fSW;
                                        fAMData2.Directory      = directory;
                                        fAMData2.FileMask       = fSW.MangledFilter;
                                        fAMData2.IncludeSubdirs = true;
                                        fAMData2.SubDirs        = new Hashtable();
                                        fAMData2.Enabled        = true;
                                        arrayList.Add(fAMData2);
                                        arrayList.Add(fAMData);
                                    }
                                }
                                if (!(filename != fAMData.Directory) || fSW.Pattern.IsMatch(filename))
                                {
                                    lock (fSW)
                                    {
                                        fSW.DispatchEvents(fileAction, filename, ref renamed);
                                        if (fSW.Waiting)
                                        {
                                            fSW.Waiting = false;
                                            System.Threading.Monitor.PulseAll(fSW);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }while (FAMPending(ref conn) > 0);
            }
            if (arrayList != null)
            {
                int count = arrayList.Count;
                for (int i = 0; i < count; i += 2)
                {
                    FAMData fAMData3 = (FAMData)arrayList[i];
                    FAMData fAMData4 = (FAMData)arrayList[i + 1];
                    StartMonitoringDirectory(fAMData3, justcreated: true);
                    requests[fAMData3.Request.ReqNum] = fAMData3;
                    lock (fAMData4)
                    {
                        fAMData4.SubDirs[fAMData3.Directory] = fAMData3;
                    }
                }
                arrayList.Clear();
            }
        }