File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -700,6 +700,21 @@ public interface ISftpClient : IBaseClient
700700 /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
701701 SftpFileAttributes GetAttributes ( string path ) ;
702702
703+ /// <summary>
704+ /// Gets the <see cref="SftpFileAttributes"/> of the file on the path.
705+ /// </summary>
706+ /// <param name="path">The path to the file.</param>
707+ /// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
708+ /// <returns>
709+ /// A <see cref="Task{SftpFileAttributes}"/> that represents the attribute retrieval operation.
710+ /// The task result contains the <see cref="SftpFileAttributes"/> of the file on the path.
711+ /// </returns>
712+ /// <exception cref="ArgumentNullException"><paramref name="path"/> is <see langword="null"/>.</exception>
713+ /// <exception cref="SshConnectionException">Client is not connected.</exception>
714+ /// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
715+ /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
716+ Task < SftpFileAttributes > GetAttributesAsync ( string path , CancellationToken cancellationToken ) ;
717+
703718 /// <summary>
704719 /// Returns the date and time the specified file or directory was last accessed.
705720 /// </summary>
Original file line number Diff line number Diff line change @@ -2094,6 +2094,33 @@ public SftpFileAttributes GetAttributes(string path)
20942094 return _sftpSession . RequestLStat ( fullPath ) ;
20952095 }
20962096
2097+ /// <summary>
2098+ /// Gets the <see cref="SftpFileAttributes"/> of the file on the path.
2099+ /// </summary>
2100+ /// <param name="path">The path to the file.</param>
2101+ /// <param name="cancellationToken">The <see cref="CancellationToken"/> to observe.</param>
2102+ /// <returns>
2103+ /// A <see cref="Task{SftpFileAttributes}"/> that represents the attribute retrieval operation.
2104+ /// The task result contains the <see cref="SftpFileAttributes"/> of the file on the path.
2105+ /// </returns>
2106+ /// <exception cref="ArgumentNullException"><paramref name="path"/> is <see langword="null"/>.</exception>
2107+ /// <exception cref="SshConnectionException">Client is not connected.</exception>
2108+ /// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
2109+ /// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
2110+ public async Task < SftpFileAttributes > GetAttributesAsync ( string path , CancellationToken cancellationToken )
2111+ {
2112+ CheckDisposed ( ) ;
2113+
2114+ if ( _sftpSession is null )
2115+ {
2116+ throw new SshConnectionException ( "Client not connected." ) ;
2117+ }
2118+
2119+ var fullPath = await _sftpSession . GetCanonicalPathAsync ( path , cancellationToken ) . ConfigureAwait ( false ) ;
2120+
2121+ return await _sftpSession . RequestLStatAsync ( fullPath , cancellationToken ) . ConfigureAwait ( false ) ;
2122+ }
2123+
20972124 /// <summary>
20982125 /// Sets the specified <see cref="SftpFileAttributes"/> of the file on the specified path.
20992126 /// </summary>
You can’t perform that action at this time.
0 commit comments