public ListDirectory ( SuperPutty.Scp.BrowserFileInfo path ) : SuperPutty.Scp.ListDirectoryResult | ||
path | SuperPutty.Scp.BrowserFileInfo | |
Результат | SuperPutty.Scp.ListDirectoryResult |
/// <summary> /// Sync call to list directory contents /// </summary> /// <param name="session"></param> /// <param name="path"></param> /// <returns></returns> public ListDirectoryResult ListDirectory(SessionData session, BrowserFileInfo path) { ListDirectoryResult result; if (session == null || session.Username == null) { result = new ListDirectoryResult(path) { ErrorMsg = "Session invalid", StatusCode = ResultStatusCode.Error }; } else { string targetPath = path.Path; if (targetPath == null || targetPath == ".") { targetPath = string.Format("/home/{0}", session.Username); Log.InfoFormat("Defaulting path: {0}->{1}", path.Path, targetPath); path.Path = targetPath; } PscpClient client = new PscpClient(this.Options, session); result = client.ListDirectory(path); } return(result); }
/// <summary> /// Sync call to list directory contents /// </summary> /// <param name="session"></param> /// <param name="path"></param> /// <returns></returns> public ListDirectoryResult ListDirectory(SessionData session, BrowserFileInfo path) { ListDirectoryResult result; if (session == null || session.Username == null) { result = new ListDirectoryResult(path); result.ErrorMsg = "Session invalid"; result.StatusCode = ResultStatusCode.Error; } else { string targetPath = path.Path; if (targetPath == null || targetPath == ".") { targetPath = string.Format("/home/{0}", session.Username); Log.InfoFormat("Defaulting path: {0}->{1}", path.Path, targetPath); path.Path = targetPath; } PscpClient client = new PscpClient(this.Options, session); result = client.ListDirectory(path); } return result; }
public void ListDirBadPath() { SessionData session = new SessionData { Username = ScpConfig.UserName, Password = ScpConfig.Password, Host = ScpConfig.KnownHost, Port = 22 }; PscpClient client = new PscpClient(ScpConfig.DefaultOptions, session); ListDirectoryResult res = client.ListDirectory(new BrowserFileInfo { Path = "some_non_existant_dir" }); Assert.AreEqual(ResultStatusCode.Error, res.StatusCode); Assert.AreEqual(0, res.Files.Count); Assert.IsTrue(res.ErrorMsg != null && res.ErrorMsg.StartsWith("Unable to open")); Log.InfoFormat("Result: {0}", res); }
public void ListDirHostNoKey() { SessionData session = new SessionData { Username = ScpConfig.UserName, Password = ScpConfig.Password, Host = ScpConfig.UnKnownHost, Port = 22 }; PscpClient client = new PscpClient(ScpConfig.DefaultOptions, session); ListDirectoryResult res = client.ListDirectory(new BrowserFileInfo { Path = "." }); Assert.AreEqual(ResultStatusCode.Error, res.StatusCode); Assert.AreEqual(res.Files.Count, 0); Log.InfoFormat("Result: {0}", res); }
public void ListDirSuccess() { SessionData session = new SessionData { Username = ScpConfig.UserName, Password = ScpConfig.Password, Host = ScpConfig.KnownHost, Port = 22 }; PscpClient client = new PscpClient(ScpConfig.DefaultOptions, session); ListDirectoryResult res = client.ListDirectory(new BrowserFileInfo { Path = "." }); Assert.AreEqual(ResultStatusCode.Success, res.StatusCode); Assert.Greater(res.Files.Count, 0); foreach (BrowserFileInfo file in res.Files) { Log.Info(file); } Log.InfoFormat("Result: {0}", res); }