Renci.SshNet.Sftp.SftpSession.RequestRealPath C# (CSharp) Method

RequestRealPath() private method

Performs SSH_FXP_REALPATH request
private RequestRealPath ( string path, bool nullOnError = false ) : SftpFileAttributes>[].KeyValuePair
path string The path.
nullOnError bool if set to true returns null instead of throwing an exception.
return SftpFileAttributes>[].KeyValuePair
        internal KeyValuePair<string, SftpFileAttributes>[] RequestRealPath(string path, bool nullOnError = false)
        {
            SshException exception = null;

            KeyValuePair<string, SftpFileAttributes>[] result = null;

            using (var wait = new AutoResetEvent(false))
            {
                var request = new SftpRealPathRequest(ProtocolVersion, NextRequestId, path, Encoding,
                    response =>
                        {
                            result = response.Files;
                            wait.Set();
                        },
                    response =>
                        {
                            exception = GetSftpException(response);
                            wait.Set();
                        });

                SendRequest(request);

                WaitOnHandle(wait, OperationTimeout);
            }

            if (!nullOnError && exception != null)
            {
                throw exception;
            }
            
            return result;
        }

Usage Example

コード例 #1
0
ファイル: SftpFilesystem.cs プロジェクト: cpascal/win-sshfs
        protected override void OnConnected()
        {
            base.OnConnected();

            _sftpSession = new SftpSession(Session, _operationTimeout, Encoding.UTF8);

            _sftpSession.Connect();

            _userId = GetUserId();
            if (_userId != -1)
                _userGroups = new HashSet<int>(GetUserGroupsIds());

            if (String.IsNullOrWhiteSpace(_rootpath))
            {
                _rootpath = _sftpSession.RequestRealPath(".").First().Key;
            }

            _supportsPosixRename =
                _sftpSession._supportedExtensions.Contains(new KeyValuePair<string, string>("*****@*****.**", "1"));
            _supportsStatVfs =
                _sftpSession._supportedExtensions.Contains(new KeyValuePair<string, string>("*****@*****.**", "2"));
            // KeepAliveInterval=TimeSpan.FromSeconds(5);

               //  Session.Disconnected+= (sender, args) => Debugger.Break();
        }