public string ProcessResult(string remoteNodeTimeZone, SftpCommandResult result) { var text = Regex.Replace(result.Output, @"\s{2,}", " "); var lines = Regex.Split(text, "\r\n|\r|\n").ToList(); string path = lines[1].Replace("Remote working directory: ", ""); return(path); }
public void ProcessResult(string remoteNodeTimeZone, SftpCommandResult result) { using (FileStream fs = File.OpenRead(_localFile)) { fs.CopyTo(_stream); } _stream.Position = 0; File.Delete(_localFile); }
public IEnumerable <SftpFile> ProcessResult(string timeZone, SftpCommandResult result) { var text = Regex.Replace(result.Output, @"\s{2,}", " "); var lines = Regex.Split(text, "\r\n|\r|\n").ToList(); //Remove first (command) and last line lines.RemoveAt(0); lines.RemoveAt(lines.Count - 1); var files = new List <SftpFile>(); foreach (var line in lines) { var tokens = line.Split(' '); string access = tokens[0]; char type = access[0]; string month = tokens[5]; string day = tokens[6]; string otherDateAttr = tokens[7]; //can be year or actual time string name = tokens[8]; string fullName = Path.Combine(_remoteWorkingDirectory, _remotePath, name); if (!DateTime.TryParseExact($"{month} {day} {otherDateAttr}", "MMM d yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out DateTime converted) && !DateTime.TryParseExact($"{month} {day} {otherDateAttr}", "MMM d HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out converted)) { throw new NotSupportedException(); } files.Add(new SftpFile { IsSymbolicLink = type == 'l', IsDirectory = type == 'd', Name = name, FullName = fullName, LastWriteTime = converted.Convert(timeZone) }); } return(files); }
public void ProcessResult(string remoteNodeTimeZone, SftpCommandResult result) { throw new Exception("ProcessResult method is not defined!"); }
public bool ProcessResult(string remoteNodeTimeZone, SftpCommandResult result) { return(result.ExitStatus == 0); }