Class: HrrRbSftp::Protocol::Version2::Packets::SSH_FXP_RENAME
- Inherits:
-
Packets::Packet
- Object
- Packets::Packet
- HrrRbSftp::Protocol::Version2::Packets::SSH_FXP_RENAME
- Defined in:
- lib/hrr_rb_sftp/protocol/version2/packets/018_ssh_fxp_rename.rb
Overview
This class implements SFTP protocol version 2 SSH_FXP_RENAME packet type, format, and responder.
Constant Summary collapse
- TYPE =
Represents SSH_FXP_RENAME packet type.
18
- FORMAT =
Represents SSH_FXP_RENAME packet format.
[ [DataTypes::Byte, :"type" ], [DataTypes::Uint32, :"request-id"], [DataTypes::String, :"oldpath" ], [DataTypes::String, :"newpath" ], ]
Instance Method Summary collapse
-
#respond_to(request) ⇒ Hash{Symbol=>Object}
Responds to SSH_FXP_RENAME request.
Instance Method Details
#respond_to(request) ⇒ Hash{Symbol=>Object}
Responds to SSH_FXP_RENAME request.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/hrr_rb_sftp/protocol/version2/packets/018_ssh_fxp_rename.rb', line 32 def respond_to request begin oldpath = request[:"oldpath"] newpath = request[:"newpath"] log_debug { "File.exist?(#{newpath.inspect})" } if File.exist?(newpath) log_debug { "File exists" } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_FAILURE, :"error message" => "File exists", :"language tag" => "", } else log_debug { "File does not exist" } log_debug { "File.rename(#{oldpath.inspect}, #{newpath.inspect})" } File.rename(oldpath, newpath) { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_OK, :"error message" => "Success", :"language tag" => "", } end rescue Errno::ENOENT => e log_debug { e. } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_NO_SUCH_FILE, :"error message" => "No such file or directory", :"language tag" => "", } rescue Errno::EACCES => e log_debug { e. } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_PERMISSION_DENIED, :"error message" => "Permission denied", :"language tag" => "", } rescue => e log_error { [e.backtrace[0], ": ", e., " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_FAILURE, :"error message" => e., :"language tag" => "", } end end |