private void SFTPOpenDirectory_Core(string fullPath, bool expand) { Log("Retrieving directory entries...: " + fullPath); SFTPFileInfo[] entries = _sftp.GetDirectoryEntries(fullPath); for (int i = 0; i < entries.Length; i++) { SFTPFileInfo ent = entries[i]; if (UnixPermissions.IsSymbolicLink(ent.Permissions)) { // If the symbolic link points a directory, // replace the file information so as to open the node. string path = CombineUnixPath(fullPath, ent.FileName); SFTPFileAttributes attr; try { attr = _sftp.GetFileInformations(path, false); } catch (SFTPClientException e) { if (!IsSFTPError(e, SFTPStatusCode.SSH_FX_NO_SUCH_FILE)) { throw; } // file missing or dead symbolic link ? attr = null; } if (attr != null) { if (UnixPermissions.IsDirectory(attr.Permissions)) { entries[i] = new SFTPFileInfo(ent.FileName, ent.LongName, attr); } } } } this.Invoke((MethodInvoker) delegate() { treeViewRemote.BeginUpdate(); TreeNode dirNode = MakeDirectoryTree(fullPath, expand); UpdateTreeDirectoryEntries(dirNode, entries); dirNode.EnsureVisible(); treeViewRemote.EndUpdate(); }); Log("...Done"); }
public static NodeTag CreateForFileOrDirectory(SFTPFileInfo fileInfo) { NodeType nodeType; string prefix; if (UnixPermissions.IsDirectory(fileInfo.Permissions)) { nodeType = NodeType.Directory; prefix = "D:"; } else if (UnixPermissions.IsSymbolicLink(fileInfo.Permissions)) { nodeType = NodeType.SymbolicLink; prefix = "F:"; } else { nodeType = NodeType.File; prefix = "F:"; } return(new NodeTag(nodeType, prefix + fileInfo.FileName, fileInfo)); }