/// <summary>Return a FileStatus representing the given path.</summary> /// <remarks> /// Return a FileStatus representing the given path. If the path refers /// to a symlink return a FileStatus representing the link rather than /// the object the link refers to. /// </remarks> /// <exception cref="System.IO.IOException"/> public override FileStatus GetFileLinkStatus(Path f) { FileStatus fi = GetFileLinkStatusInternal(f, false); // getFileLinkStatus is supposed to return a symlink with a // qualified path if (fi.IsSymlink()) { Path targetQual = FSLinkResolver.QualifySymlinkTarget(this.GetUri(), fi.GetPath() , fi.GetSymlink()); fi.SetSymlink(targetQual); } return(fi); }
/// <summary> /// Attempt calling overridden /// <see cref="FileSystemLinkResolver{T}.DoCall(Path)"/> /// method with /// specified /// <see cref="FileSystem"/> /// and /// <see cref="Path"/> /// . If the call fails with an /// UnresolvedLinkException, it will try to resolve the path and retry the call /// by calling /// <see cref="FileSystemLinkResolver{T}.Next(FileSystem, Path)"/> /// . /// </summary> /// <param name="filesys">FileSystem with which to try call</param> /// <param name="path">Path with which to try call</param> /// <returns>Generic type determined by implementation</returns> /// <exception cref="System.IO.IOException"/> public virtual T Resolve(FileSystem filesys, Path path) { int count = 0; T @in = null; Path p = path; // Assumes path belongs to this FileSystem. // Callers validate this by passing paths through FileSystem#checkPath FileSystem fs = filesys; for (bool isLink = true; isLink;) { try { @in = DoCall(p); isLink = false; } catch (UnresolvedLinkException e) { if (!filesys.resolveSymlinks) { throw new IOException("Path " + path + " contains a symlink" + " and symlink resolution is disabled (" + CommonConfigurationKeys.FsClientResolveRemoteSymlinksKey + ").", e); } if (!FileSystem.AreSymlinksEnabled()) { throw new IOException("Symlink resolution is disabled in" + " this version of Hadoop." ); } if (count++ > FsConstants.MaxPathLinks) { throw new IOException("Possible cyclic loop while " + "following symbolic link " + path); } // Resolve the first unresolved path component p = FSLinkResolver.QualifySymlinkTarget(fs.GetUri(), p, filesys.ResolveLink(p)); fs = FileSystem.GetFSofPath(p, filesys.GetConf()); // Have to call next if it's a new FS if (!fs.Equals(filesys)) { return(Next(fs, p)); } } } // Else, we keep resolving with this filesystem // Successful call, path was fully resolved return(@in); }