public static string GetParentPath(string path, string root) { if (ADPathHelper.EndsWithDelimiter(path, CanonicalPath.delimiterChar, CanonicalPath.escapeChar)) { path = path.Substring(0, path.Length - 1); } if (ADPathHelper.EndsWithDelimiter(root, CanonicalPath.delimiterChar, CanonicalPath.escapeChar)) { root = root.Substring(0, root.Length - 1); } if (!string.Equals(path, root, StringComparison.InvariantCultureIgnoreCase)) { int num = ADPathHelper.IndexOfLastDelimiter(path, CanonicalPath.delimiterChar, CanonicalPath.escapeChar); if (num < 0 || num >= path.Length - 1) { return(""); } else { return(path.Substring(0, num)); } } else { return(""); } }
public static string GetChildName(string path) { if (ADPathHelper.EndsWithDelimiter(path, CanonicalPath.delimiterChar, CanonicalPath.escapeChar)) { path = path.Substring(0, path.Length - 1); } int num = ADPathHelper.IndexOfLastDelimiter(path, CanonicalPath.delimiterChar, CanonicalPath.escapeChar); if (num < 0 || num >= path.Length - 1) { return(path); } else { return(path.Substring(num + 1)); } }
public static bool ComparePath(string path1, string path2) { if (ADPathHelper.StartsWithDelimiter(path1, CanonicalPath.delimiterChar)) { path1 = path1.Substring(1); } if (ADPathHelper.StartsWithDelimiter(path2, CanonicalPath.delimiterChar)) { path2 = path2.Substring(1); } if (ADPathHelper.EndsWithDelimiter(path1, CanonicalPath.delimiterChar, CanonicalPath.escapeChar)) { path1 = path1.Substring(0, path1.Length - 1); } if (ADPathHelper.EndsWithDelimiter(path2, CanonicalPath.delimiterChar, CanonicalPath.escapeChar)) { path2 = path2.Substring(0, path2.Length - 1); } return(path1.Equals(path2, StringComparison.OrdinalIgnoreCase)); }
public static string MakePath(string parent, string child) { if (!ADPathHelper.StartsWithDelimiter(parent, X500Path.delimiterChar) || !ADPathHelper.EndsWithDelimiter(child, X500Path.delimiterChar, X500Path.escapeChar)) { if (ADPathHelper.StartsWithDelimiter(parent, X500Path.delimiterChar) || ADPathHelper.EndsWithDelimiter(child, X500Path.delimiterChar, X500Path.escapeChar)) { return(string.Concat(child, parent)); } else { return(string.Concat(child, X500Path.delimiterChar, parent)); } } else { return(string.Concat(child, parent.Substring(1))); } }