[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 {
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;
+ }
}
}