New test.
[mono.git] / mcs / class / corlib / System.IO / Path.cs
index 4a9b5e57b1c42d01b4c8d059fa12e7f44e3d667d..44b391d69985552c95395ea8cebc03344c95fa18 100644 (file)
@@ -52,7 +52,7 @@ namespace System.IO {
        [ComVisible (true)]
        public static class Path {
 
-               [Obsolete ("see GetInvalidPathChars and GetInvalidfileNameChars methods.")]
+               [Obsolete ("see GetInvalidPathChars and GetInvalidFileNameChars methods.")]
                public static readonly char[] InvalidPathChars;
 #else
        public sealed class Path {
@@ -586,5 +586,29 @@ namespace System.IO {
                                return ret;
                        }
                }
+
+               // required for FileIOPermission (and most proibably reusable elsewhere too)
+               // both path MUST be "full paths"
+               static internal bool IsPathSubsetOf (string subset, string path)
+               {
+                       if (subset.Length > path.Length)
+                               return false;
+
+                       // check that everything up to the last separator match
+                       int slast = subset.LastIndexOfAny (PathSeparatorChars);
+                       if (String.Compare (subset, 0, path, 0, slast) != 0)
+                               return false;
+
+                       slast++;
+                       // then check if the last segment is identical
+                       int plast = path.IndexOfAny (PathSeparatorChars, slast);
+                       if (plast >= slast) {
+                               return String.Compare (subset, slast, path, slast, path.Length - plast) == 0;
+                       }
+                       if (subset.Length != path.Length)
+                               return false;
+
+                       return String.Compare (subset, slast, path, slast, subset.Length - slast) == 0;
+               }
        }
 }