From: Marek Habersack Date: Mon, 26 Jan 2009 13:26:21 +0000 (-0000) Subject: 2009-01-26 Marek Habersack X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=21c73210aada3a9a2079e1ce27c6a1480167bf07;p=mono.git 2009-01-26 Marek Habersack * 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 --- diff --git a/mcs/class/System/System.IO/ChangeLog b/mcs/class/System/System.IO/ChangeLog index 0731e983ca0..3d4e250d84e 100644 --- a/mcs/class/System/System.IO/ChangeLog +++ b/mcs/class/System/System.IO/ChangeLog @@ -1,3 +1,12 @@ +2009-01-26 Marek Habersack + + * 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 * MonoIO.cs : Add DuplicateHandle. diff --git a/mcs/class/System/System.IO/SearchPattern.cs b/mcs/class/System/System.IO/SearchPattern.cs index 6dd1aed5874..0fbab4e5e7e 100644 --- a/mcs/class/System/System.IO/SearchPattern.cs +++ b/mcs/class/System/System.IO/SearchPattern.cs @@ -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); }