Sha256: 4849f082beef318d6a4b5d51696cec228d6bc0a966685915310bc0d4493c6e6d

Contents?: true

Size: 618 Bytes

Versions: 6

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

require_relative 'command_handler'

module Ftpd

  class CmdType < CommandHandler

    def cmd_type(argument)
      ensure_logged_in
      syntax_error unless argument =~ /^(\S)(?: (\S+))?$/
      type_code = $1
      format_code = $2
      unless argument =~ /^([AEI]( [NTC])?|L .*)$/
        error 'Invalid type code', 504
      end
      case argument
      when /^A( [NT])?$/
        self.data_type = 'A'
      when /^(I|L 8)$/
        self.data_type = 'I'
      else
        error 'Type not implemented', 504
      end
      reply "200 Type set to #{data_type}"
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ftpd-2.0.5 lib/ftpd/cmd_type.rb
ftpd-2.0.4 lib/ftpd/cmd_type.rb
ftpd-2.0.3 lib/ftpd/cmd_type.rb
ftpd-2.0.2 lib/ftpd/cmd_type.rb
ftpd-2.0.1 lib/ftpd/cmd_type.rb
ftpd-2.0.0 lib/ftpd/cmd_type.rb