|
@@ -2,7 +2,6 @@
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
using System.Threading;
|
|
|
-using Renci.SshNet.Channels;
|
|
|
|
|
using Renci.SshNet.Common;
|
|
using Renci.SshNet.Common;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
@@ -13,9 +12,9 @@ namespace Renci.SshNet.Sftp
|
|
|
{
|
|
{
|
|
|
internal class SftpSession : SubsystemSession
|
|
internal class SftpSession : SubsystemSession
|
|
|
{
|
|
{
|
|
|
- private const int MAXIMUM_SUPPORTED_VERSION = 3;
|
|
|
|
|
|
|
+ private const int MaximumSupportedVersion = 3;
|
|
|
|
|
|
|
|
- private const int MINIMUM_SUPPORTED_VERSION = 0;
|
|
|
|
|
|
|
+ private const int MinimumSupportedVersion = 0;
|
|
|
|
|
|
|
|
private readonly Dictionary<uint, SftpRequest> _requests = new Dictionary<uint, SftpRequest>();
|
|
private readonly Dictionary<uint, SftpRequest> _requests = new Dictionary<uint, SftpRequest>();
|
|
|
|
|
|
|
@@ -51,7 +50,7 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
return (uint)this._requestId;
|
|
return (uint)this._requestId;
|
|
|
#else
|
|
#else
|
|
|
- return ((uint)Interlocked.Increment(ref this._requestId));
|
|
|
|
|
|
|
+ return ((uint)Interlocked.Increment(ref _requestId));
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -63,13 +62,13 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
public void ChangeDirectory(string path)
|
|
public void ChangeDirectory(string path)
|
|
|
{
|
|
{
|
|
|
- var fullPath = this.GetCanonicalPath(path);
|
|
|
|
|
|
|
+ var fullPath = GetCanonicalPath(path);
|
|
|
|
|
|
|
|
- var handle = this.RequestOpenDir(fullPath);
|
|
|
|
|
|
|
+ var handle = RequestOpenDir(fullPath);
|
|
|
|
|
|
|
|
- this.RequestClose(handle);
|
|
|
|
|
|
|
+ RequestClose(handle);
|
|
|
|
|
|
|
|
- this.WorkingDirectory = fullPath;
|
|
|
|
|
|
|
+ WorkingDirectory = fullPath;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
internal void SendMessage(SftpMessage sftpMessage)
|
|
internal void SendMessage(SftpMessage sftpMessage)
|
|
@@ -81,7 +80,7 @@ namespace Renci.SshNet.Sftp
|
|
|
((uint)messageData.Length).GetBytes().CopyTo(data, 0);
|
|
((uint)messageData.Length).GetBytes().CopyTo(data, 0);
|
|
|
messageData.CopyTo(data, 4);
|
|
messageData.CopyTo(data, 4);
|
|
|
|
|
|
|
|
- this.SendData(data);
|
|
|
|
|
|
|
+ SendData(data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -95,7 +94,7 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
var canonizedPath = string.Empty;
|
|
var canonizedPath = string.Empty;
|
|
|
|
|
|
|
|
- var realPathFiles = this.RequestRealPath(fullPath, true);
|
|
|
|
|
|
|
+ var realPathFiles = RequestRealPath(fullPath, true);
|
|
|
|
|
|
|
|
if (realPathFiles != null)
|
|
if (realPathFiles != null)
|
|
|
{
|
|
{
|
|
@@ -112,14 +111,14 @@ namespace Renci.SshNet.Sftp
|
|
|
fullPath.IndexOf('/') < 0)
|
|
fullPath.IndexOf('/') < 0)
|
|
|
return fullPath;
|
|
return fullPath;
|
|
|
|
|
|
|
|
- var pathParts = fullPath.Split(new char[] { '/' });
|
|
|
|
|
|
|
+ var pathParts = fullPath.Split(new[] { '/' });
|
|
|
|
|
|
|
|
var partialFullPath = string.Join("/", pathParts, 0, pathParts.Length - 1);
|
|
var partialFullPath = string.Join("/", pathParts, 0, pathParts.Length - 1);
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(partialFullPath))
|
|
if (string.IsNullOrEmpty(partialFullPath))
|
|
|
partialFullPath = "/";
|
|
partialFullPath = "/";
|
|
|
|
|
|
|
|
- realPathFiles = this.RequestRealPath(partialFullPath, true);
|
|
|
|
|
|
|
+ realPathFiles = RequestRealPath(partialFullPath, true);
|
|
|
|
|
|
|
|
if (realPathFiles != null)
|
|
if (realPathFiles != null)
|
|
|
{
|
|
{
|
|
@@ -141,15 +140,15 @@ namespace Renci.SshNet.Sftp
|
|
|
{
|
|
{
|
|
|
var fullPath = path;
|
|
var fullPath = path;
|
|
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(path) && path[0] != '/' && this.WorkingDirectory != null)
|
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(path) && path[0] != '/' && WorkingDirectory != null)
|
|
|
{
|
|
{
|
|
|
- if (this.WorkingDirectory[this.WorkingDirectory.Length - 1] == '/')
|
|
|
|
|
|
|
+ if (WorkingDirectory[WorkingDirectory.Length - 1] == '/')
|
|
|
{
|
|
{
|
|
|
- fullPath = string.Format(CultureInfo.InvariantCulture, "{0}{1}", this.WorkingDirectory, path);
|
|
|
|
|
|
|
+ fullPath = string.Format(CultureInfo.InvariantCulture, "{0}{1}", WorkingDirectory, path);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", this.WorkingDirectory, path);
|
|
|
|
|
|
|
+ fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", WorkingDirectory, path);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return fullPath;
|
|
return fullPath;
|
|
@@ -157,67 +156,67 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
protected override void OnChannelOpen()
|
|
protected override void OnChannelOpen()
|
|
|
{
|
|
{
|
|
|
- this.SendMessage(new SftpInitRequest(MAXIMUM_SUPPORTED_VERSION));
|
|
|
|
|
|
|
+ SendMessage(new SftpInitRequest(MaximumSupportedVersion));
|
|
|
|
|
|
|
|
- this.WaitOnHandle(this._sftpVersionConfirmed, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(_sftpVersionConfirmed, OperationTimeout);
|
|
|
|
|
|
|
|
- if (this.ProtocolVersion > MAXIMUM_SUPPORTED_VERSION || this.ProtocolVersion < MINIMUM_SUPPORTED_VERSION)
|
|
|
|
|
|
|
+ if (ProtocolVersion > MaximumSupportedVersion || ProtocolVersion < MinimumSupportedVersion)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Server SFTP version {0} is not supported.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Server SFTP version {0} is not supported.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Resolve current directory
|
|
// Resolve current directory
|
|
|
- this.WorkingDirectory = this.RequestRealPath(".").First().Key;
|
|
|
|
|
|
|
+ WorkingDirectory = RequestRealPath(".").First().Key;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected override void OnDataReceived(uint dataTypeCode, byte[] data)
|
|
protected override void OnDataReceived(uint dataTypeCode, byte[] data)
|
|
|
{
|
|
{
|
|
|
// Add channel data to internal data holder
|
|
// Add channel data to internal data holder
|
|
|
- this._data.AddRange(data);
|
|
|
|
|
|
|
+ _data.AddRange(data);
|
|
|
|
|
|
|
|
- while (this._data.Count > 4 + 1)
|
|
|
|
|
|
|
+ while (_data.Count > 4 + 1)
|
|
|
{
|
|
{
|
|
|
// Extract packet length
|
|
// Extract packet length
|
|
|
- var packetLength = (this._data[0] << 24 | this._data[1] << 16 | this._data[2] << 8 | this._data[3]);
|
|
|
|
|
|
|
+ var packetLength = (_data[0] << 24 | _data[1] << 16 | _data[2] << 8 | _data[3]);
|
|
|
|
|
|
|
|
// Check if complete packet data is available
|
|
// Check if complete packet data is available
|
|
|
- if (this._data.Count < packetLength + 4)
|
|
|
|
|
|
|
+ if (_data.Count < packetLength + 4)
|
|
|
{
|
|
{
|
|
|
// Wait for complete message to arrive first
|
|
// Wait for complete message to arrive first
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- this._data.RemoveRange(0, 4);
|
|
|
|
|
|
|
+ _data.RemoveRange(0, 4);
|
|
|
|
|
|
|
|
// Create buffer to hold packet data
|
|
// Create buffer to hold packet data
|
|
|
var packetData = new byte[packetLength];
|
|
var packetData = new byte[packetLength];
|
|
|
|
|
|
|
|
// Cope packet data to array
|
|
// Cope packet data to array
|
|
|
- this._data.CopyTo(0, packetData, 0, packetLength);
|
|
|
|
|
|
|
+ _data.CopyTo(0, packetData, 0, packetLength);
|
|
|
|
|
|
|
|
// Remove loaded data from _data holder
|
|
// Remove loaded data from _data holder
|
|
|
- this._data.RemoveRange(0, packetLength);
|
|
|
|
|
|
|
+ _data.RemoveRange(0, packetLength);
|
|
|
|
|
|
|
|
// Load SFTP Message and handle it
|
|
// Load SFTP Message and handle it
|
|
|
- var response = SftpMessage.Load(this.ProtocolVersion, packetData, this.Encoding);
|
|
|
|
|
|
|
+ var response = SftpMessage.Load(ProtocolVersion, packetData, Encoding);
|
|
|
|
|
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
var versionResponse = response as SftpVersionResponse;
|
|
var versionResponse = response as SftpVersionResponse;
|
|
|
if (versionResponse != null)
|
|
if (versionResponse != null)
|
|
|
{
|
|
{
|
|
|
- this.ProtocolVersion = versionResponse.Version;
|
|
|
|
|
- this._supportedExtensions = versionResponse.Extentions;
|
|
|
|
|
|
|
+ ProtocolVersion = versionResponse.Version;
|
|
|
|
|
+ _supportedExtensions = versionResponse.Extentions;
|
|
|
|
|
|
|
|
- this._sftpVersionConfirmed.Set();
|
|
|
|
|
|
|
+ _sftpVersionConfirmed.Set();
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- this.HandleResponse(response as SftpResponse);
|
|
|
|
|
|
|
+ HandleResponse(response as SftpResponse);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
catch (Exception exp)
|
|
catch (Exception exp)
|
|
|
{
|
|
{
|
|
|
- this.RaiseError(exp);
|
|
|
|
|
|
|
+ RaiseError(exp);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -229,22 +228,22 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
if (disposing)
|
|
if (disposing)
|
|
|
{
|
|
{
|
|
|
- if (this._sftpVersionConfirmed != null)
|
|
|
|
|
|
|
+ if (_sftpVersionConfirmed != null)
|
|
|
{
|
|
{
|
|
|
- this._sftpVersionConfirmed.Dispose();
|
|
|
|
|
- this._sftpVersionConfirmed = null;
|
|
|
|
|
|
|
+ _sftpVersionConfirmed.Dispose();
|
|
|
|
|
+ _sftpVersionConfirmed = null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void SendRequest(SftpRequest request)
|
|
private void SendRequest(SftpRequest request)
|
|
|
{
|
|
{
|
|
|
- lock (this._requests)
|
|
|
|
|
|
|
+ lock (_requests)
|
|
|
{
|
|
{
|
|
|
- this._requests.Add(request.RequestId, request);
|
|
|
|
|
|
|
+ _requests.Add(request.RequestId, request);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.SendMessage(request);
|
|
|
|
|
|
|
+ SendMessage(request);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#region SFTP API functions
|
|
#region SFTP API functions
|
|
@@ -263,21 +262,21 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpOpenRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding, flags,
|
|
|
|
|
|
|
+ var request = new SftpOpenRequest(ProtocolVersion, NextRequestId, path, Encoding, flags,
|
|
|
response =>
|
|
response =>
|
|
|
- {
|
|
|
|
|
- handle = response.Handle;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ handle = response.Handle;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
response =>
|
|
response =>
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!nullOnError && exception != null)
|
|
if (!nullOnError && exception != null)
|
|
@@ -298,16 +297,16 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpCloseRequest(this.ProtocolVersion, this.NextRequestId, handle,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpCloseRequest(ProtocolVersion, NextRequestId, handle,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -331,24 +330,24 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpReadRequest(this.ProtocolVersion, this.NextRequestId, handle, offset, length,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- data = response.Data;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- if (response.StatusCode != StatusCodes.Eof)
|
|
|
|
|
|
|
+ var request = new SftpReadRequest(ProtocolVersion, NextRequestId, handle, offset, length,
|
|
|
|
|
+ response =>
|
|
|
{
|
|
{
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- }
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ data = response.Data;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ if (response.StatusCode != StatusCodes.Eof)
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ }
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -371,23 +370,23 @@ namespace Renci.SshNet.Sftp
|
|
|
{
|
|
{
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
|
|
|
|
|
|
- var request = new SftpWriteRequest(this.ProtocolVersion, this.NextRequestId, handle, offset, data,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- if (writeCompleted != null)
|
|
|
|
|
|
|
+ var request = new SftpWriteRequest(ProtocolVersion, NextRequestId, handle, offset, data,
|
|
|
|
|
+ response =>
|
|
|
{
|
|
{
|
|
|
- writeCompleted(response);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (writeCompleted != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ writeCompleted(response);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- if (wait != null)
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ if (wait != null)
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
if (wait != null)
|
|
if (wait != null)
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
|
{
|
|
{
|
|
@@ -409,21 +408,21 @@ namespace Renci.SshNet.Sftp
|
|
|
SftpFileAttributes attributes = null;
|
|
SftpFileAttributes attributes = null;
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpLStatRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- attributes = response.Attributes;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpLStatRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ attributes = response.Attributes;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -448,21 +447,21 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpFStatRequest(this.ProtocolVersion, this.NextRequestId, handle,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- attributes = response.Attributes;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ var request = new SftpFStatRequest(ProtocolVersion, NextRequestId, handle,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ attributes = response.Attributes;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
(response) =>
|
|
(response) =>
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -484,16 +483,16 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpSetStatRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding, attributes,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpSetStatRequest(ProtocolVersion, NextRequestId, path, Encoding, attributes,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -513,16 +512,16 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpFSetStatRequest(this.ProtocolVersion, this.NextRequestId, handle, attributes,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpFSetStatRequest(ProtocolVersion, NextRequestId, handle, attributes,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -545,21 +544,21 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpOpenDirRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- handle = response.Handle;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpOpenDirRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ handle = response.Handle;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!nullOnError && exception != null)
|
|
if (!nullOnError && exception != null)
|
|
@@ -583,24 +582,24 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpReadDirRequest(this.ProtocolVersion, this.NextRequestId, handle,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- result = response.Files;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- if (response.StatusCode != StatusCodes.Eof)
|
|
|
|
|
|
|
+ var request = new SftpReadDirRequest(ProtocolVersion, NextRequestId, handle,
|
|
|
|
|
+ response =>
|
|
|
{
|
|
{
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- }
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ result = response.Files;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ if (response.StatusCode != StatusCodes.Eof)
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ }
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -621,16 +620,16 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpRemoveRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpRemoveRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -649,16 +648,16 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpMkDirRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpMkDirRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -677,16 +676,16 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpRmDirRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpRmDirRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -709,21 +708,21 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpRealPathRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- result = response.Files;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpRealPathRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ result = response.Files;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!nullOnError && exception != null)
|
|
if (!nullOnError && exception != null)
|
|
@@ -750,21 +749,21 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpStatRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- attributes = response.Attributes;
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpStatRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ attributes = response.Attributes;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!nullOnError && exception != null)
|
|
if (!nullOnError && exception != null)
|
|
@@ -782,25 +781,25 @@ namespace Renci.SshNet.Sftp
|
|
|
/// <param name="newPath">The new path.</param>
|
|
/// <param name="newPath">The new path.</param>
|
|
|
internal void RequestRename(string oldPath, string newPath)
|
|
internal void RequestRename(string oldPath, string newPath)
|
|
|
{
|
|
{
|
|
|
- if (this.ProtocolVersion < 2)
|
|
|
|
|
|
|
+ if (ProtocolVersion < 2)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_RENAME operation is not supported in {0} version that server operates in.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_RENAME operation is not supported in {0} version that server operates in.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpRenameRequest(this.ProtocolVersion, this.NextRequestId, oldPath, newPath, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpRenameRequest(ProtocolVersion, NextRequestId, oldPath, newPath, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -817,9 +816,9 @@ namespace Renci.SshNet.Sftp
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
internal KeyValuePair<string, SftpFileAttributes>[] RequestReadLink(string path, bool nullOnError = false)
|
|
internal KeyValuePair<string, SftpFileAttributes>[] RequestReadLink(string path, bool nullOnError = false)
|
|
|
{
|
|
{
|
|
|
- if (this.ProtocolVersion < 3)
|
|
|
|
|
|
|
+ if (ProtocolVersion < 3)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_READLINK operation is not supported in {0} version that server operates in.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_READLINK operation is not supported in {0} version that server operates in.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
@@ -828,22 +827,21 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpReadLinkRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- result = response.Files;
|
|
|
|
|
-
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpReadLinkRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ result = response.Files;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!nullOnError && exception != null)
|
|
if (!nullOnError && exception != null)
|
|
@@ -861,25 +859,25 @@ namespace Renci.SshNet.Sftp
|
|
|
/// <param name="targetpath">The targetpath.</param>
|
|
/// <param name="targetpath">The targetpath.</param>
|
|
|
internal void RequestSymLink(string linkpath, string targetpath)
|
|
internal void RequestSymLink(string linkpath, string targetpath)
|
|
|
{
|
|
{
|
|
|
- if (this.ProtocolVersion < 3)
|
|
|
|
|
|
|
+ if (ProtocolVersion < 3)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_SYMLINK operation is not supported in {0} version that server operates in.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_SYMLINK operation is not supported in {0} version that server operates in.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new SftpSymLinkRequest(this.ProtocolVersion, this.NextRequestId, linkpath, targetpath, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new SftpSymLinkRequest(ProtocolVersion, NextRequestId, linkpath, targetpath, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -899,28 +897,28 @@ namespace Renci.SshNet.Sftp
|
|
|
/// <param name="newPath">The new path.</param>
|
|
/// <param name="newPath">The new path.</param>
|
|
|
internal void RequestPosixRename(string oldPath, string newPath)
|
|
internal void RequestPosixRename(string oldPath, string newPath)
|
|
|
{
|
|
{
|
|
|
- if (this.ProtocolVersion < 3)
|
|
|
|
|
|
|
+ if (ProtocolVersion < 3)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new PosixRenameRequest(this.ProtocolVersion, this.NextRequestId, oldPath, newPath, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new PosixRenameRequest(ProtocolVersion, NextRequestId, oldPath, newPath, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- if (!this._supportedExtensions.ContainsKey(request.Name))
|
|
|
|
|
|
|
+ if (!_supportedExtensions.ContainsKey(request.Name))
|
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -937,9 +935,9 @@ namespace Renci.SshNet.Sftp
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
internal SftpFileSytemInformation RequestStatVfs(string path, bool nullOnError = false)
|
|
internal SftpFileSytemInformation RequestStatVfs(string path, bool nullOnError = false)
|
|
|
{
|
|
{
|
|
|
- if (this.ProtocolVersion < 3)
|
|
|
|
|
|
|
+ if (ProtocolVersion < 3)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
@@ -948,25 +946,24 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new StatVfsRequest(this.ProtocolVersion, this.NextRequestId, path, this.Encoding,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- information = response.GetReply<StatVfsReplyInfo>().Information;
|
|
|
|
|
-
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new StatVfsRequest(ProtocolVersion, NextRequestId, path, Encoding,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ information = response.GetReply<StatVfsReplyInfo>().Information;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- if (!this._supportedExtensions.ContainsKey(request.Name))
|
|
|
|
|
|
|
+ if (!_supportedExtensions.ContainsKey(request.Name))
|
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!nullOnError && exception != null)
|
|
if (!nullOnError && exception != null)
|
|
@@ -986,9 +983,9 @@ namespace Renci.SshNet.Sftp
|
|
|
/// <exception cref="System.NotSupportedException"></exception>
|
|
/// <exception cref="System.NotSupportedException"></exception>
|
|
|
internal SftpFileSytemInformation RequestFStatVfs(byte[] handle, bool nullOnError = false)
|
|
internal SftpFileSytemInformation RequestFStatVfs(byte[] handle, bool nullOnError = false)
|
|
|
{
|
|
{
|
|
|
- if (this.ProtocolVersion < 3)
|
|
|
|
|
|
|
+ if (ProtocolVersion < 3)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
@@ -997,25 +994,24 @@ namespace Renci.SshNet.Sftp
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new FStatVfsRequest(this.ProtocolVersion, this.NextRequestId, handle,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- information = response.GetReply<StatVfsReplyInfo>().Information;
|
|
|
|
|
-
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- },
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new FStatVfsRequest(ProtocolVersion, NextRequestId, handle,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ information = response.GetReply<StatVfsReplyInfo>().Information;
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ },
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- if (!this._supportedExtensions.ContainsKey(request.Name))
|
|
|
|
|
|
|
+ if (!_supportedExtensions.ContainsKey(request.Name))
|
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!nullOnError && exception != null)
|
|
if (!nullOnError && exception != null)
|
|
@@ -1033,28 +1029,28 @@ namespace Renci.SshNet.Sftp
|
|
|
/// <param name="newPath">The new path.</param>
|
|
/// <param name="newPath">The new path.</param>
|
|
|
internal void HardLink(string oldPath, string newPath)
|
|
internal void HardLink(string oldPath, string newPath)
|
|
|
{
|
|
{
|
|
|
- if (this.ProtocolVersion < 3)
|
|
|
|
|
|
|
+ if (ProtocolVersion < 3)
|
|
|
{
|
|
{
|
|
|
- throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", this.ProtocolVersion));
|
|
|
|
|
|
|
+ throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "SSH_FXP_EXTENDED operation is not supported in {0} version that server operates in.", ProtocolVersion));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SshException exception = null;
|
|
SshException exception = null;
|
|
|
|
|
|
|
|
using (var wait = new AutoResetEvent(false))
|
|
using (var wait = new AutoResetEvent(false))
|
|
|
{
|
|
{
|
|
|
- var request = new HardLinkRequest(this.ProtocolVersion, this.NextRequestId, oldPath, newPath,
|
|
|
|
|
- (response) =>
|
|
|
|
|
- {
|
|
|
|
|
- exception = this.GetSftpException(response);
|
|
|
|
|
- wait.Set();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ var request = new HardLinkRequest(ProtocolVersion, NextRequestId, oldPath, newPath,
|
|
|
|
|
+ response =>
|
|
|
|
|
+ {
|
|
|
|
|
+ exception = GetSftpException(response);
|
|
|
|
|
+ wait.Set();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- if (!this._supportedExtensions.ContainsKey(request.Name))
|
|
|
|
|
|
|
+ if (!_supportedExtensions.ContainsKey(request.Name))
|
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Extension method {0} currently not supported by the server.", request.Name));
|
|
|
|
|
|
|
|
- this.SendRequest(request);
|
|
|
|
|
|
|
+ SendRequest(request);
|
|
|
|
|
|
|
|
- this.WaitOnHandle(wait, this._operationTimeout);
|
|
|
|
|
|
|
+ WaitOnHandle(wait, OperationTimeout);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (exception != null)
|
|
if (exception != null)
|
|
@@ -1126,25 +1122,22 @@ namespace Renci.SshNet.Sftp
|
|
|
{
|
|
{
|
|
|
return new SftpPermissionDeniedException(response.ErrorMessage);
|
|
return new SftpPermissionDeniedException(response.ErrorMessage);
|
|
|
}
|
|
}
|
|
|
- else if (response.StatusCode == StatusCodes.NoSuchFile)
|
|
|
|
|
|
|
+ if (response.StatusCode == StatusCodes.NoSuchFile)
|
|
|
{
|
|
{
|
|
|
return new SftpPathNotFoundException(response.ErrorMessage);
|
|
return new SftpPathNotFoundException(response.ErrorMessage);
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- return new SshException(response.ErrorMessage);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return new SshException(response.ErrorMessage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void HandleResponse(SftpResponse response)
|
|
private void HandleResponse(SftpResponse response)
|
|
|
{
|
|
{
|
|
|
SftpRequest request;
|
|
SftpRequest request;
|
|
|
- lock (this._requests)
|
|
|
|
|
|
|
+ lock (_requests)
|
|
|
{
|
|
{
|
|
|
- this._requests.TryGetValue(response.ResponseId, out request);
|
|
|
|
|
|
|
+ _requests.TryGetValue(response.ResponseId, out request);
|
|
|
if (request != null)
|
|
if (request != null)
|
|
|
{
|
|
{
|
|
|
- this._requests.Remove(response.ResponseId);
|
|
|
|
|
|
|
+ _requests.Remove(response.ResponseId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|