Class: Net::SFTP::Protocol::V06::Base

Overview

Wraps the low-level SFTP calls for version 6 of the SFTP protocol.

None of these protocol methods block–all of them return immediately, requiring the SSH event loop to be run while the server response is pending.

You will almost certainly never need to use this driver directly. Please see Net::SFTP::Session for the recommended interface.

Constant Summary

Constants included from Constants::PacketTypes

Constants::PacketTypes::FXP_ATTRS, Constants::PacketTypes::FXP_BLOCK, Constants::PacketTypes::FXP_CLOSE, Constants::PacketTypes::FXP_DATA, Constants::PacketTypes::FXP_EXTENDED, Constants::PacketTypes::FXP_EXTENDED_REPLY, Constants::PacketTypes::FXP_FSETSTAT, Constants::PacketTypes::FXP_FSTAT, Constants::PacketTypes::FXP_HANDLE, Constants::PacketTypes::FXP_INIT, Constants::PacketTypes::FXP_LINK, Constants::PacketTypes::FXP_LSTAT, Constants::PacketTypes::FXP_MKDIR, Constants::PacketTypes::FXP_NAME, Constants::PacketTypes::FXP_OPEN, Constants::PacketTypes::FXP_OPENDIR, Constants::PacketTypes::FXP_READ, Constants::PacketTypes::FXP_READDIR, Constants::PacketTypes::FXP_READLINK, Constants::PacketTypes::FXP_REALPATH, Constants::PacketTypes::FXP_REMOVE, Constants::PacketTypes::FXP_RENAME, Constants::PacketTypes::FXP_RMDIR, Constants::PacketTypes::FXP_SETSTAT, Constants::PacketTypes::FXP_STAT, Constants::PacketTypes::FXP_STATUS, Constants::PacketTypes::FXP_SYMLINK, Constants::PacketTypes::FXP_UNBLOCK, Constants::PacketTypes::FXP_VERSION, Constants::PacketTypes::FXP_WRITE

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods inherited from Net::SFTP::Protocol::V05::Base

#open, #rename

Methods inherited from Net::SFTP::Protocol::V04::Base

#fstat, #lstat, #parse_name_packet, #stat

Methods inherited from Net::SFTP::Protocol::V03::Base

#readlink

Methods inherited from Net::SFTP::Protocol::V02::Base

#rename

Methods inherited from Net::SFTP::Protocol::V01::Base

#close, #fsetstat, #fstat, #lstat, #mkdir, #open, #opendir, #parse_attrs_packet, #parse_data_packet, #parse_handle_packet, #parse_name_packet, #parse_status_packet, #read, #readdir, #readlink, #realpath, #remove, #rename, #rmdir, #setstat, #stat, #write

Methods inherited from Base

#initialize, #parse

Constructor Details

This class inherits a constructor from Net::SFTP::Protocol::Base

Instance Method Details

#block(handle, offset, length, mask) ⇒ Object

Sends a FXP_BLOCK packet to the server to request that a byte-range lock be obtained on the given handle, for the given byte offset and length. The mask parameter is a bitfield indicating what kind of lock to acquire, and must be a combination of one or more of the Net::SFTP::Constants::LockTypes constants.



41
42
43
# File 'lib/net/sftp/protocol/06/base.rb', line 41

def block(handle, offset, length, mask)
  send_request(FXP_BLOCK, :string, handle, :int64, offset, :int64, length, :long, mask)
end

Sends a FXP_LINK packet to the server to request that a link be created at new_link_path, pointing to existing_path. If symlink is true, a symbolic link will be created; otherwise a hard link will be created.



25
26
27
# File 'lib/net/sftp/protocol/06/base.rb', line 25

def link(new_link_path, existing_path, symlink)
  send_request(FXP_LINK, :string, new_link_path, :string, existing_path, :bool, symlink)
end

Provided for backwards compatibility; v6 of the SFTP protocol removes the older FXP_SYMLINK packet type, so this method simply calls the #link method.



32
33
34
# File 'lib/net/sftp/protocol/06/base.rb', line 32

def symlink(path, target)
  link(path, target, true)
end

#unblock(handle, offset, length) ⇒ Object

Sends a FXP_UNBLOCK packet to the server to request that a previously acquired byte-range lock be released on the given handle, for the given byte offset and length. The handle, offset, and length must all exactly match the parameters that were given when the lock was originally acquired (see #block).



50
51
52
# File 'lib/net/sftp/protocol/06/base.rb', line 50

def unblock(handle, offset, length)
  send_request(FXP_UNBLOCK, :string, handle, :int64, offset, :int64, length)
end

#versionObject

Returns the protocol version implemented by this driver. (6, in this case)



18
19
20
# File 'lib/net/sftp/protocol/06/base.rb', line 18

def version
  6
end