Skip to content

Commit

Permalink
Add getRealPath parameter to GetCanonized function
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Bedoya Ortecho committed Aug 24, 2023
1 parent 4577899 commit de4b777
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Renci.SshNet/Sftp/ISftpSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ internal interface ISftpSession : ISubsystemSession
/// Resolves a given path into an absolute path on the server.
/// </summary>
/// <param name="path">The path to resolve.</param>
/// <param name="getRealPath">Boolean determining whether to get the ral path.</param>
/// <returns>
/// The absolute path.
/// </returns>
string GetCanonicalPath(string path);
string GetCanonicalPath(string path, bool getRealPath = true);

Task<string> GetCanonicalPathAsync(string path, CancellationToken cancellationToken);

Expand Down
9 changes: 8 additions & 1 deletion src/Renci.SshNet/Sftp/SftpSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,20 @@ internal void SendMessage(SftpMessage sftpMessage)
/// Resolves a given path into an absolute path on the server.
/// </summary>
/// <param name="path">The path to resolve.</param>
/// <param name="getRealPath">Boolean determining whether to get the real path.</param>
/// <returns>
/// The absolute path.
/// </returns>
public string GetCanonicalPath(string path)
public string GetCanonicalPath(string path, bool getRealPath = true)
{
var fullPath = GetFullRemotePath(path);

if (!getRealPath)
{
// getRealPath set to false allows us to get a reference to the symbolic link itself and not to the file it points to.
return fullPath;
}

var canonizedPath = string.Empty;

var realPathFiles = RequestRealPath(fullPath, nullOnError: true);
Expand Down

0 comments on commit de4b777

Please sign in to comment.