Class: HrrRbSftp::Protocol::Version1::Packet::SSH_FXP_LSTAT
- Inherits:
-
Object
- Object
- HrrRbSftp::Protocol::Version1::Packet::SSH_FXP_LSTAT
- Includes:
- Common::Packetable
- Defined in:
- lib/hrr_rb_sftp/protocol/version1/packet/007_ssh_fxp_lstat.rb
Constant Summary collapse
- TYPE =
7
- FORMAT =
[ [DataType::Byte, :"type" ], [DataType::Uint32, :"request-id"], [DataType::String, :"path" ], ]
Instance Attribute Summary
Attributes included from Loggable
Instance Method Summary collapse
Methods included from Common::Packetable
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Instance Method Details
#respond_to(request) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 |
# File 'lib/hrr_rb_sftp/protocol/version1/packet/007_ssh_fxp_lstat.rb', line 16 def respond_to request begin stat = File.lstat(request[:"path"]) attrs = Hash.new attrs[:"size"] = stat.size if stat.size attrs[:"uid"] = stat.uid if stat.uid attrs[:"gid"] = stat.gid if stat.gid attrs[:"permissions"] = stat.mode if stat.mode attrs[:"atime"] = stat.atime.to_i if stat.atime attrs[:"mtime"] = stat.mtime.to_i if stat.mtime { :"type" => SSH_FXP_ATTRS::TYPE, :"request-id" => request[:"request-id"], :"attrs" => attrs, } rescue Errno::ENOENT { :"type" => SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => SSH_FXP_STATUS::SSH_FX_NO_SUCH_FILE, :"error message" => "No such file or directory", :"language tag" => "", } rescue Errno::EACCES { :"type" => SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => 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" => SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => SSH_FXP_STATUS::SSH_FX_FAILURE, :"error message" => e., :"language tag" => "", } end end |