Skip to content

Commit cb1f26d

Browse files
authored
Internal cleanup in SftpSession (#1717)
Delete some Begin/End methods, use <inheritdoc/>
1 parent cd9ec8f commit cb1f26d

File tree

7 files changed

+63
-814
lines changed

7 files changed

+63
-814
lines changed

src/Renci.SshNet/Sftp/ISftpSession.cs

Lines changed: 7 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,10 @@ internal interface ISftpSession : ISubsystemSession
8787
/// Performs SSH_FXP_STAT request.
8888
/// </summary>
8989
/// <param name="path">The path.</param>
90-
/// <param name="nullOnError">If set to <see langword="true"/>, <see langword="null"/> is returned in case of an error.</param>
9190
/// <returns>
9291
/// File attributes.
9392
/// </returns>
94-
SftpFileAttributes RequestStat(string path, bool nullOnError = false);
95-
96-
/// <summary>
97-
/// Performs SSH_FXP_STAT request.
98-
/// </summary>
99-
/// <param name="path">The path.</param>
100-
/// <param name="callback">The <see cref="AsyncCallback"/> delegate that is executed when <see cref="BeginOpen(string, Flags, AsyncCallback, object)"/> completes.</param>
101-
/// <param name="state">An object that contains any additional user-defined data.</param>
102-
/// <returns>
103-
/// A <see cref="SftpOpenAsyncResult"/> that represents the asynchronous call.
104-
/// </returns>
105-
SFtpStatAsyncResult BeginStat(string path, AsyncCallback callback, object state);
106-
107-
/// <summary>
108-
/// Handles the end of an asynchronous read.
109-
/// </summary>
110-
/// <param name="asyncResult">An <see cref="SFtpStatAsyncResult"/> that represents an asynchronous call.</param>
111-
/// <returns>
112-
/// The file attributes.
113-
/// </returns>
114-
/// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is <see langword="null"/>.</exception>
115-
SftpFileAttributes EndStat(SFtpStatAsyncResult asyncResult);
93+
SftpFileAttributes RequestStat(string path);
11694

11795
/// <summary>
11896
/// Performs SSH_FXP_LSTAT request.
@@ -134,27 +112,6 @@ internal interface ISftpSession : ISubsystemSession
134112
/// </returns>
135113
Task<SftpFileAttributes> RequestLStatAsync(string path, CancellationToken cancellationToken);
136114

137-
/// <summary>
138-
/// Performs SSH_FXP_LSTAT request.
139-
/// </summary>
140-
/// <param name="path">The path.</param>
141-
/// <param name="callback">The <see cref="AsyncCallback"/> delegate that is executed when <see cref="BeginLStat(string, AsyncCallback, object)"/> completes.</param>
142-
/// <param name="state">An object that contains any additional user-defined data.</param>
143-
/// <returns>
144-
/// A <see cref="SFtpStatAsyncResult"/> that represents the asynchronous call.
145-
/// </returns>
146-
SFtpStatAsyncResult BeginLStat(string path, AsyncCallback callback, object state);
147-
148-
/// <summary>
149-
/// Handles the end of an asynchronous SSH_FXP_LSTAT request.
150-
/// </summary>
151-
/// <param name="asyncResult">An <see cref="SFtpStatAsyncResult"/> that represents an asynchronous call.</param>
152-
/// <returns>
153-
/// The file attributes.
154-
/// </returns>
155-
/// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is <see langword="null"/>.</exception>
156-
SftpFileAttributes EndLStat(SFtpStatAsyncResult asyncResult);
157-
158115
/// <summary>
159116
/// Performs SSH_FXP_MKDIR request.
160117
/// </summary>
@@ -174,11 +131,10 @@ internal interface ISftpSession : ISubsystemSession
174131
/// </summary>
175132
/// <param name="path">The path.</param>
176133
/// <param name="flags">The flags.</param>
177-
/// <param name="nullOnError">If set to <see langword="true"/>, <see langword="null"/> is returned in case of an error.</param>
178134
/// <returns>
179135
/// The file handle for the specified path.
180136
/// </returns>
181-
byte[] RequestOpen(string path, Flags flags, bool nullOnError = false);
137+
byte[] RequestOpen(string path, Flags flags);
182138

183139
/// <summary>
184140
/// Asynchronously performs a <c>SSH_FXP_OPEN</c> request.
@@ -192,41 +148,14 @@ internal interface ISftpSession : ISubsystemSession
192148
/// </returns>
193149
Task<byte[]> RequestOpenAsync(string path, Flags flags, CancellationToken cancellationToken);
194150

195-
/// <summary>
196-
/// Performs SSH_FXP_OPEN request.
197-
/// </summary>
198-
/// <param name="path">The path.</param>
199-
/// <param name="flags">The flags.</param>
200-
/// <param name="callback">The <see cref="AsyncCallback"/> delegate that is executed when <see cref="BeginOpen(string, Flags, AsyncCallback, object)"/> completes.</param>
201-
/// <param name="state">An object that contains any additional user-defined data.</param>
202-
/// <returns>
203-
/// A <see cref="SftpOpenAsyncResult"/> that represents the asynchronous call.
204-
/// </returns>
205-
SftpOpenAsyncResult BeginOpen(string path, Flags flags, AsyncCallback callback, object state);
206-
207-
/// <summary>
208-
/// Handles the end of an asynchronous read.
209-
/// </summary>
210-
/// <param name="asyncResult">An <see cref="SftpOpenAsyncResult"/> that represents an asynchronous call.</param>
211-
/// <returns>
212-
/// A <see cref="byte"/> array representing a file handle.
213-
/// </returns>
214-
/// <remarks>
215-
/// If all available data has been read, the <see cref="EndOpen(SftpOpenAsyncResult)"/> method completes
216-
/// immediately and returns zero bytes.
217-
/// </remarks>
218-
/// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is <see langword="null"/>.</exception>
219-
byte[] EndOpen(SftpOpenAsyncResult asyncResult);
220-
221151
/// <summary>
222152
/// Performs a <c>SSH_FXP_OPENDIR</c> request.
223153
/// </summary>
224154
/// <param name="path">The path.</param>
225-
/// <param name="nullOnError">If set to <see langword="true"/>, <see langword="null"/> is returned in case of an error.</param>
226155
/// <returns>
227156
/// A file handle for the specified path.
228157
/// </returns>
229-
byte[] RequestOpenDir(string path, bool nullOnError = false);
158+
byte[] RequestOpenDir(string path);
230159

231160
/// <summary>
232161
/// Asynchronously performs a <c>SSH_FXP_OPENDIR</c> request.
@@ -252,35 +181,10 @@ internal interface ISftpSession : ISubsystemSession
252181
/// <param name="handle">The handle.</param>
253182
/// <param name="offset">The offset.</param>
254183
/// <param name="length">The length.</param>
255-
/// <returns>data array; null if EOF.</returns>
256-
byte[] RequestRead(byte[] handle, ulong offset, uint length);
257-
258-
/// <summary>
259-
/// Begins an asynchronous read using a SSH_FXP_READ request.
260-
/// </summary>
261-
/// <param name="handle">The handle to the file to read from.</param>
262-
/// <param name="offset">The offset in the file to start reading from.</param>
263-
/// <param name="length">The number of bytes to read.</param>
264-
/// <param name="callback">The <see cref="AsyncCallback"/> delegate that is executed when <see cref="BeginRead(byte[], ulong, uint, AsyncCallback, object)"/> completes.</param>
265-
/// <param name="state">An object that contains any additional user-defined data.</param>
266184
/// <returns>
267-
/// A <see cref="SftpReadAsyncResult"/> that represents the asynchronous call.
185+
/// The data that was read, or an empty array when the end of the file was reached.
268186
/// </returns>
269-
SftpReadAsyncResult BeginRead(byte[] handle, ulong offset, uint length, AsyncCallback callback, object state);
270-
271-
/// <summary>
272-
/// Handles the end of an asynchronous read.
273-
/// </summary>
274-
/// <param name="asyncResult">An <see cref="SftpReadAsyncResult"/> that represents an asynchronous call.</param>
275-
/// <returns>
276-
/// A <see cref="byte"/> array representing the data read.
277-
/// </returns>
278-
/// <remarks>
279-
/// If all available data has been read, the <see cref="EndRead(SftpReadAsyncResult)"/> method completes
280-
/// immediately and returns zero bytes.
281-
/// </remarks>
282-
/// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is <see langword="null"/>.</exception>
283-
byte[] EndRead(SftpReadAsyncResult asyncResult);
187+
byte[] RequestRead(byte[] handle, ulong offset, uint length);
284188

285189
/// <summary>
286190
/// Asynchronously performs a <c>SSH_FXP_READ</c> request.
@@ -319,27 +223,6 @@ internal interface ISftpSession : ISubsystemSession
319223
/// </returns>
320224
Task<KeyValuePair<string, SftpFileAttributes>[]> RequestReadDirAsync(byte[] handle, CancellationToken cancellationToken);
321225

322-
/// <summary>
323-
/// Performs SSH_FXP_REALPATH request.
324-
/// </summary>
325-
/// <param name="path">The path.</param>
326-
/// <param name="callback">The <see cref="AsyncCallback"/> delegate that is executed when <see cref="BeginRealPath(string, AsyncCallback, object)"/> completes.</param>
327-
/// <param name="state">An object that contains any additional user-defined data.</param>
328-
/// <returns>
329-
/// A <see cref="SftpRealPathAsyncResult"/> that represents the asynchronous call.
330-
/// </returns>
331-
SftpRealPathAsyncResult BeginRealPath(string path, AsyncCallback callback, object state);
332-
333-
/// <summary>
334-
/// Handles the end of an asynchronous SSH_FXP_REALPATH request.
335-
/// </summary>
336-
/// <param name="asyncResult">An <see cref="SftpRealPathAsyncResult"/> that represents an asynchronous call.</param>
337-
/// <returns>
338-
/// The absolute path.
339-
/// </returns>
340-
/// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is <see langword="null"/>.</exception>
341-
string EndRealPath(SftpRealPathAsyncResult asyncResult);
342-
343226
/// <summary>
344227
/// Performs a <c>SSH_FXP_REMOVE</c> request.
345228
/// </summary>
@@ -401,12 +284,10 @@ internal interface ISftpSession : ISubsystemSession
401284
/// Performs a <c>statvfs@openssh.com</c> extended request.
402285
/// </summary>
403286
/// <param name="path">The path.</param>
404-
/// <param name="nullOnError">If set to <see langword="true"/>, <see langword="null"/> is returned in case of an error.</param>
405287
/// <returns>
406-
/// The file system information for the specified path, or <see langword="null"/> when
407-
/// the request failed and <paramref name="nullOnError"/> is <see langword="true"/>.
288+
/// The file system information for the specified path.
408289
/// </returns>
409-
SftpFileSystemInformation RequestStatVfs(string path, bool nullOnError = false);
290+
SftpFileSystemInformation RequestStatVfs(string path);
410291

411292
/// <summary>
412293
/// Asynchronously performs a <c>statvfs@openssh.com</c> extended request.
@@ -482,24 +363,6 @@ void RequestWrite(byte[] handle,
482363
/// </returns>
483364
Task RequestCloseAsync(byte[] handle, CancellationToken cancellationToken);
484365

485-
/// <summary>
486-
/// Performs SSH_FXP_CLOSE request.
487-
/// </summary>
488-
/// <param name="handle">The handle.</param>
489-
/// <param name="callback">The <see cref="AsyncCallback"/> delegate that is executed when <see cref="BeginClose(byte[], AsyncCallback, object)"/> completes.</param>
490-
/// <param name="state">An object that contains any additional user-defined data.</param>
491-
/// <returns>
492-
/// A <see cref="SftpCloseAsyncResult"/> that represents the asynchronous call.
493-
/// </returns>
494-
SftpCloseAsyncResult BeginClose(byte[] handle, AsyncCallback callback, object state);
495-
496-
/// <summary>
497-
/// Handles the end of an asynchronous close.
498-
/// </summary>
499-
/// <param name="asyncResult">An <see cref="SftpCloseAsyncResult"/> that represents an asynchronous call.</param>
500-
/// <exception cref="ArgumentNullException"><paramref name="asyncResult"/> is <see langword="null"/>.</exception>
501-
void EndClose(SftpCloseAsyncResult asyncResult);
502-
503366
/// <summary>
504367
/// Calculates the optimal size of the buffer to read data from the channel.
505368
/// </summary>

src/Renci.SshNet/Sftp/SftpCloseAsyncResult.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Renci.SshNet/Sftp/SftpOpenAsyncResult.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Renci.SshNet/Sftp/SftpRealPathAsyncResult.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)