Skip to content

Commit de4b777

Browse files
author
Fernando Bedoya Ortecho
committed
Add getRealPath parameter to GetCanonized function
1 parent 4577899 commit de4b777

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Renci.SshNet/Sftp/ISftpSession.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ internal interface ISftpSession : ISubsystemSession
3535
/// Resolves a given path into an absolute path on the server.
3636
/// </summary>
3737
/// <param name="path">The path to resolve.</param>
38+
/// <param name="getRealPath">Boolean determining whether to get the ral path.</param>
3839
/// <returns>
3940
/// The absolute path.
4041
/// </returns>
41-
string GetCanonicalPath(string path);
42+
string GetCanonicalPath(string path, bool getRealPath = true);
4243

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

src/Renci.SshNet/Sftp/SftpSession.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,20 @@ internal void SendMessage(SftpMessage sftpMessage)
8989
/// Resolves a given path into an absolute path on the server.
9090
/// </summary>
9191
/// <param name="path">The path to resolve.</param>
92+
/// <param name="getRealPath">Boolean determining whether to get the real path.</param>
9293
/// <returns>
9394
/// The absolute path.
9495
/// </returns>
95-
public string GetCanonicalPath(string path)
96+
public string GetCanonicalPath(string path, bool getRealPath = true)
9697
{
9798
var fullPath = GetFullRemotePath(path);
9899

100+
if (!getRealPath)
101+
{
102+
// getRealPath set to false allows us to get a reference to the symbolic link itself and not to the file it points to.
103+
return fullPath;
104+
}
105+
99106
var canonizedPath = string.Empty;
100107

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

0 commit comments

Comments
 (0)