2006-04-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 6 Apr 2006 22:16:48 +0000 (22:16 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 6 Apr 2006 22:16:48 +0000 (22:16 -0000)
* FAMWatcher.cs: add new directories to the hashtable after start
monitoring them, otherwise the ReqNum is not set. Fixes bug #78029.

svn path=/trunk/mcs/; revision=59147

mcs/class/System/System.IO/ChangeLog
mcs/class/System/System.IO/FAMWatcher.cs

index 60916fb8fa037292c02e13e520affcf2f49697e4..ae8fffb932f7a4e871ea73f2e646f266f72ad0ff 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * FAMWatcher.cs: add new directories to the hashtable after start
+       monitoring them, otherwise the ReqNum is not set. Fixes bug #78029.
+
 2006-01-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * FAMWatcher.cs: fix arraylist access when a new directory is added and
index af86050280b164eff924f29409467c34ac5f7ecf..40973d699d83e2cbf7d611576fb9f93f1f12a230 100644 (file)
@@ -280,11 +280,15 @@ namespace System.IO {
                                                string full = fsw.FullPath;
                                                string datadir = data.Directory;
                                                if (datadir != full) {
-                                                       string reldir = datadir.Substring (full.Length + 1);
+                                                       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 (fsw.FullPath, filename);
+                                                       datadir = Path.Combine (full, filename);
                                                }
 
                                                if (fa == FileAction.Added && Directory.Exists (datadir)) {
@@ -300,7 +304,6 @@ namespace System.IO {
                                                        fd.Enabled = true;
                                                        newdirs.Add (fd);
                                                        newdirs.Add (data);
-                                                       requests [fd.Request.ReqNum] = fd;
                                                }
                                        }
 
@@ -324,6 +327,7 @@ namespace System.IO {
                                        FAMData newdir = (FAMData) newdirs [n];
                                        FAMData parent = (FAMData) newdirs [n + 1];
                                        StartMonitoringDirectory (newdir);
+                                       requests [newdir.Request.ReqNum] = newdir;
                                        lock (parent) {
                                                parent.SubDirs [newdir.Directory] = newdir;
                                        }