public void Path_FileInNonRootDirectory() { var path = "/home/sshnet/xyz"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual("xyz", actual); }
public void Path_BackslashIsNotConsideredDirectorySeparator() { var path = "/home\\abc.log"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual("home\\abc.log", actual); }
public void Path_FileInRootDirectory() { var path = "/abc.log"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual("abc.log", actual); }
public void Path_RootDirectoryOnly() { var path = "/"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual(string.Empty, actual); }
public void Path_TrailingForwardSlash() { var path = "/abc/"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual(string.Empty, actual); }
public void Path_FileWithoutNoDirectory() { var path = "abc.log"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreSame(path, actual); }
public void Path_FileNameOnlyWhitespace() { var path = "/home/\t "; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual("\t ", actual); }
public void Path_Empty() { var path = string.Empty; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreSame(path, actual); }
public void Path_TrailingWhitespace() { var path = "/abc \t "; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual("abc \t ", actual); }
public void Path_LeadingWhitespace() { var path = " / \tabc"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual(" \tabc", actual); }
public void Path_ColonIsNotConsideredPathSeparator() { var path = "/home:abc.log"; var actual = PosixPath.GetFileName(path); Assert.IsNotNull(actual); Assert.AreEqual("home:abc.log", actual); }
public void Path_Null() { const string path = null; try { PosixPath.GetFileName(path); Assert.Fail(); } catch (NullReferenceException) { } }
public void Path_Null() { const string path = null; try { PosixPath.GetFileName(path); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.IsNull(ex.InnerException); Assert.AreEqual("path", ex.ParamName); } }
/// <summary> /// Uploads the specified stream to the remote host. /// </summary> /// <param name="source">The <see cref="Stream"/> to upload.</param> /// <param name="path">A relative or absolute path for the remote file.</param> /// <exception cref="ScpException">A directory with the specified path exists on the remote host.</exception> /// <exception cref="SshException">The secure copy execution request was rejected by the server.</exception> public void Upload(Stream source, string path) { using (var input = ServiceFactory.CreatePipeStream()) using (var channel = Session.CreateChannelSession()) { channel.DataReceived += (sender, e) => input.Write(e.Data, 0, e.Data.Length); channel.Open(); // pass the full path to ensure the server does not create the directory part // as a file in case the directory does not exist if (!channel.SendExecRequest(string.Format("scp -t {0}", _remotePathTransformation.Transform(path)))) { throw SecureExecutionRequestRejectedException(); } CheckReturnCode(input); // specify a zero-length file name to avoid creating a file with absolute // path '<path>/<filename part of path>' if directory '<path>' already exists UploadFileModeAndName(channel, input, source.Length, PosixPath.GetFileName(path)); UploadFileContent(channel, input, source, PosixPath.GetFileName(path)); } }