Sha256: 5878a45668b3618eba62845a093c703937d57934d9301d1a5b02166ac4b536a4

Contents?: true

Size: 650 Bytes

Versions: 7

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

require_relative 'command_handler'

module Ftpd

  class CmdSize < CommandHandler

    def cmd_size(path)
      ensure_logged_in
      ensure_file_system_supports :read
      syntax_error unless path
      path = File.expand_path(path, name_prefix)
      ensure_accessible(path)
      ensure_exists(path)
      file_system.read(path) do |file|
        if data_type == 'A'
          output = StringIO.new
          io = Ftpd::Stream.new(output, data_type)
          io.write(file)
          size = output.size
        else
          size = file.size
        end
        reply "213 #{size}"
      end
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

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