浏览代码

Internal changes, replace Dictionary<string,SftpFileAttributes> with KeyValuePair<string,SftpFileAttributes>[].

olegkap_cp 14 年之前
父节点
当前提交
799e6d54b9

+ 4 - 4
Renci.SshClient/Renci.SshNet/Sftp/Responses/SftpNameResponse.cs

@@ -14,11 +14,11 @@ namespace Renci.SshNet.Sftp.Responses
 
         public uint Count { get; private set; }
 
-        public IDictionary<string, SftpFileAttributes> Files { get; private set; }
+        public KeyValuePair<string, SftpFileAttributes>[] Files { get; private set; }
 
         public SftpNameResponse()
         {
-            this.Files = new Dictionary<string, SftpFileAttributes>();
+            this.Files = new KeyValuePair<string,SftpFileAttributes>[0];
         }
 
         protected override void LoadData()
@@ -26,14 +26,14 @@ namespace Renci.SshNet.Sftp.Responses
             base.LoadData();
             
             this.Count = this.ReadUInt32();
+            this.Files = new KeyValuePair<string, SftpFileAttributes>[this.Count];
             
             for (int i = 0; i < this.Count; i++)
             {
                 var fileName = this.ReadString();
                 this.ReadString();   //  This field value has meaningless information
                 var attributes = this.ReadAttributes();
-
-                this.Files.Add(fileName, attributes);
+                this.Files[i] = new KeyValuePair<string, SftpFileAttributes>(fileName, attributes);
             }
         }
     }

+ 9 - 10
Renci.SshClient/Renci.SshNet/Sftp/SftpSession.cs

@@ -105,7 +105,7 @@ namespace Renci.SshNet.Sftp
 
             if (realPathFiles != null)
             {
-                canonizedPath = realPathFiles.Keys.First();
+                canonizedPath = realPathFiles.First().Key;                
             }
 
             if (!string.IsNullOrEmpty(canonizedPath))
@@ -129,10 +129,9 @@ namespace Renci.SshNet.Sftp
 
             if (realPathFiles != null)
             {
-                canonizedPath = realPathFiles.Keys.First();
+                canonizedPath = realPathFiles.First().Key;
             }
 
-
             if (string.IsNullOrEmpty(canonizedPath))
             {
                 return fullPath;
@@ -170,7 +169,7 @@ namespace Renci.SshNet.Sftp
             this.ProtocolVersion = 3;
 
             //  Resolve current directory
-            this.WorkingDirectory = this.RequestRealPath(".").Keys.First();
+            this.WorkingDirectory = this.RequestRealPath(".").First().Key;
         }
 
         protected override void OnDataReceived(uint dataTypeCode, byte[] data)
@@ -592,9 +591,9 @@ namespace Renci.SshNet.Sftp
         /// </summary>
         /// <param name="handle">The handle.</param>
         /// <returns></returns>
-        internal IDictionary<string, SftpFileAttributes> RequestReadDir(byte[] handle)
+        internal KeyValuePair<string, SftpFileAttributes>[] RequestReadDir(byte[] handle)
         {
-            IDictionary<string, SftpFileAttributes> result = null;
+            KeyValuePair<string, SftpFileAttributes>[] result = null;
 
             using (var wait = new AutoResetEvent(false))
             {
@@ -711,9 +710,9 @@ namespace Renci.SshNet.Sftp
         /// <param name="path">The path.</param>
         /// <param name="nullOnError">if set to <c>true</c> returns null instead of throwing an exception.</param>
         /// <returns></returns>
-        internal IDictionary<string, SftpFileAttributes> RequestRealPath(string path, bool nullOnError = false)
+        internal KeyValuePair<string, SftpFileAttributes>[] RequestRealPath(string path, bool nullOnError = false)
         {
-            IDictionary<string, SftpFileAttributes> result = null;
+            KeyValuePair<string, SftpFileAttributes>[] result = null;
 
             using (var wait = new AutoResetEvent(false))
             {
@@ -817,9 +816,9 @@ namespace Renci.SshNet.Sftp
         /// <param name="path">The path.</param>
         /// <param name="nullOnError">if set to <c>true</c> returns null instead of throwing an exception.</param>
         /// <returns></returns>
-        internal IDictionary<string, SftpFileAttributes> RequestReadLink(string path, bool nullOnError = false)
+        internal KeyValuePair<string, SftpFileAttributes>[] RequestReadLink(string path, bool nullOnError = false)
         {
-            IDictionary<string, SftpFileAttributes> result = null;
+            KeyValuePair<string, SftpFileAttributes>[] result = null;
 
             using (var wait = new AutoResetEvent(false))
             {