/// <summary>Merge 2 paths such that the second path is appended relative to the first. /// </summary> /// <remarks> /// Merge 2 paths such that the second path is appended relative to the first. /// The returned path has the scheme and authority of the first path. On /// Windows, the drive specification in the second path is discarded. /// </remarks> /// <param name="path1">Path first path</param> /// <param name="path2">Path second path, to be appended relative to path1</param> /// <returns>Path merged path</returns> public static Org.Apache.Hadoop.FS.Path MergePaths(Org.Apache.Hadoop.FS.Path path1 , Org.Apache.Hadoop.FS.Path path2) { string path2Str = path2.ToUri().GetPath(); path2Str = Runtime.Substring(path2Str, StartPositionWithoutWindowsDrive(path2Str )); // Add path components explicitly, because simply concatenating two path // string is not safe, for example: // "/" + "/foo" yields "//foo", which will be parsed as authority in Path return(new Org.Apache.Hadoop.FS.Path(path1.ToUri().GetScheme(), path1.ToUri().GetAuthority (), path1.ToUri().GetPath() + path2Str)); }
public static Org.Apache.Hadoop.FS.Path GetPathWithoutSchemeAndAuthority(Org.Apache.Hadoop.FS.Path path) { // This code depends on Path.toString() to remove the leading slash before // the drive specification on Windows. Org.Apache.Hadoop.FS.Path newPath = path.IsUriPathAbsolute() ? new Org.Apache.Hadoop.FS.Path (null, null, path.ToUri().GetPath()) : path; return(newPath); }