module Net::SCP::Download

def read_directive_state(channel)

possible directives).
directive. (See the SCP protocol documentation in Net::SCP for the
This state parses the next full line (up to a new-line) for the next
def read_directive_state(channel)
  return unless line = channel[:buffer].read_to("\n")
  channel[:buffer].consume!
  directive = parse_directive(line)
  case directive[:type]
  when :OK
    return
  when :warning
    channel[:error_string] << directive[:message]
  when :error
    channel[:error_string] << directive[:message]
  when :times
    channel[:times] = directive
  when :directory
    read_directory(channel, directive)
  when :file
    read_file(channel, directive)
  when :end
    channel[:local] = File.dirname(channel[:local])
    channel[:stack].pop
    channel[:state] = :finish if channel[:stack].empty?
  end
  channel.send_data("\0")
end