Sha256: b4388e1db84414a7f557bda6115f8a82090fb5abf8c937147c6536646c13b0c0

Contents?: true

Size: 845 Bytes

Versions: 7

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

require_relative 'command_handler'

module Ftpd

  class CmdRename < CommandHandler

    def cmd_rnfr(argument)
      ensure_logged_in
      ensure_file_system_supports :rename
      syntax_error unless argument
      from_path = File.expand_path(argument, name_prefix)
      ensure_accessible from_path
      ensure_exists from_path
      @rename_from_path = from_path
      reply '350 RNFR accepted; ready for destination'
      expect 'rnto'
    end

    def cmd_rnto(argument)
      ensure_logged_in
      ensure_file_system_supports :rename
      syntax_error unless argument
      to_path = File.expand_path(argument, name_prefix)
      ensure_accessible to_path
      ensure_does_not_exist to_path
      file_system.rename(@rename_from_path, to_path)
      reply '250 Rename successful'
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

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