2009-01-26 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Mon, 26 Jan 2009 13:26:21 +0000 (13:26 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Mon, 26 Jan 2009 13:26:21 +0000 (13:26 -0000)
* SearchPattern.cs: make IsMatch work for situations when there is
no wildcard in the pattern, but a subdirectory match is being
tested, e.g. pattern == "file.txt" and text ==
"subdir/file.txt". Lack of support for this has been causing
watching for changes to ASP.NET's web.config in subdirectories to
fail.

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

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

index 0731e983ca0b0c718d4446022fa65a96f61dfe9d..3d4e250d84e637ca0a628fe126e5960923f258df 100644 (file)
@@ -1,3 +1,12 @@
+2009-01-26  Marek Habersack  <mhabersack@novell.com>
+
+       * SearchPattern.cs: make IsMatch work for situations when there is
+       no wildcard in the pattern, but a subdirectory match is being
+       tested, e.g. pattern == "file.txt" and text ==
+       "subdir/file.txt". Lack of support for this has been causing
+       watching for changes to ASP.NET's web.config in subdirectories to
+       fail.
+
 2008-11-06  Jonathan Chambers  <joncham@gmail.com>
 
        * MonoIO.cs : Add DuplicateHandle.
index 6dd1aed587470e41d89aeecb74f2522ffddeefaa..0fbab4e5e7eb3e50be08b27174d1d8efb8b7c6bf 100644 (file)
@@ -51,9 +51,23 @@ namespace System.IO {
                // so we need a overload in here for the Kqueue watcher
                public bool IsMatch (string text, bool ignorecase)
                {
-                       if (!hasWildcard)
-                               return (String.Compare (pattern, text, ignorecase) == 0);
-
+                       if (!hasWildcard) {
+                               bool match = String.Compare (pattern, text, ignorecase) == 0;
+                               if (match)
+                                       return true;
+                               
+                               // This is a special case for FSW. It needs to match e.g. subdir/file.txt
+                               // when the pattern is "file.txt"
+                               int idx = text.LastIndexOf ('/');
+                               if (idx == -1)
+                                       return false;
+                               idx++;
+                               if (idx == text.Length)
+                                       return false;
+                               
+                               return (String.Compare (pattern, text.Substring (idx), ignorecase) == 0);
+                       }
+                       
                        return Match (ops, text, 0);
                }