X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FSystem.IO%2FSearchPattern.cs;h=6dd1aed587470e41d89aeecb74f2522ffddeefaa;hb=00e065484e866f3a0349c882f804c4a79a13ee5c;hp=b2bd7839336a4dba0383565ea37aaf2ba02086bf;hpb=dbea39aa4615fb6e7d59fb185537342396450159;p=mono.git diff --git a/mcs/class/System/System.IO/SearchPattern.cs b/mcs/class/System/System.IO/SearchPattern.cs index b2bd7839336..6dd1aed5874 100644 --- a/mcs/class/System/System.IO/SearchPattern.cs +++ b/mcs/class/System/System.IO/SearchPattern.cs @@ -7,6 +7,27 @@ // (C) 2002 // +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + // Copied from corlib/System.IO/SearchPatter.cs using System; @@ -22,26 +43,43 @@ namespace System.IO { public SearchPattern2 (string pattern, bool ignore) { this.ignore = ignore; + this.pattern = pattern; Compile (pattern); } - public bool IsMatch (string text) + // OSX has a retarded case-insensitive yet case-aware filesystem + // 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); + return Match (ops, text, 0); } + public bool IsMatch (string text) + { + return IsMatch (text, ignore); + } + + public bool HasWildcard { + get { return hasWildcard; } + } // private - private Op ops; // the compiled pattern - private bool ignore; // ignore case + Op ops; // the compiled pattern + bool ignore; // ignore case + bool hasWildcard; + string pattern; private void Compile (string pattern) { if (pattern == null || pattern.IndexOfAny (InvalidChars) >= 0) - throw new ArgumentException ("Invalid search pattern."); + throw new ArgumentException ("Invalid search pattern: '" + pattern + "'"); if (pattern == "*") { // common case ops = new Op (OpCode.True); + hasWildcard = true; return; } @@ -56,11 +94,13 @@ namespace System.IO { case '?': op = new Op (OpCode.AnyChar); ++ ptr; + hasWildcard = true; break; case '*': op = new Op (OpCode.AnyString); ++ ptr; + hasWildcard = true; break; default: