Class: Net::SFTP::Protocol::V01::Base

Class | Net::SFTP::Protocol::V01::Base
In: | lib/net/sftp/protocol/01/base.rb
Parent: | Protocol::Base

Wraps the low-level SFTP calls for version 1 of the SFTP protocol. Also implements the packet parsing as defined by version 1 of the 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.

### Methods

attribute_factory block close fsetstat fstat link lstat mkdir name_factory normalize_open_flags not_implemented! 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 symlink unblock version write

### Included Modules

Net::SFTP::Constants::OpenFlags

### Public Instance methods

block(handle, offset, length, mask)

Not implemented in version 1 of the SFTP protocol. Raises a NotImplementedError if called.

close(handle)

Sends a FXP_CLOSE packet to the server for the given `handle` (such as would be returned via a FXP_HANDLE packet). Returns the new packet id.

fsetstat(handle, attrs)

Sends a FXP_FSETSTAT packet to the server, to update the attributes for the file represented by the given `handle` (which must have been obtained from a FXP_HANDLE packet). The `attrs` parameter is a hash that defines the attributes to set.

fstat(handle, flags=nil)

Sends a FXP_FSTAT packet to the server, requesting a FXP_ATTR response for the file represented by the given `handle` (which must have been obtained from a FXP_HANDLE packet). The `flags` parameter is ignored in this version of the protocol.

link(*args)

Not implemented in version 1 of the SFTP protocol. Raises a NotImplementedError if called.

lstat(path, flags=nil)

Sends a FXP_LSTAT packet to the server, requesting a FXP_ATTR response for the file at the given remote `path` (a string). The `flags` parameter is ignored in this version of the protocol. lstat will not follow symbolic links; see stat for a version that will.

mkdir(path, attrs)

Sends a FXP_MKDIR packet to the server, to request that a new directory at `path` on the remote server be created, and with `attrs` (a hash) describing the attributes of the new directory.

open(path, flags, options)

Sends a FXP_OPEN packet to the server and returns the packet identifier. The `flags` parameter is either an integer (in which case it must be a combination of the IO constants) or a string (in which case it must be one of the mode strings that IO::open accepts). The `options` parameter is a hash that is used to construct a new Attribute object, to pass as part of the FXP_OPEN request.

opendir(path)

Sends a FXP_OPENDIR packet to the server, to request a handle for manipulating the directory at the given remote `path`.

parse_attrs_packet(packet)

Parses the given FXP_ATTRS packet and returns a hash with one key, :attrs, which references an Attributes object.

parse_data_packet(packet)

Parses the given FXP_DATA packet and returns a hash with one key, :data, which references the data returned in the packet.

parse_handle_packet(packet)

Parses the given FXP_HANDLE packet and returns a hash with one key, :handle, which references the handle.

parse_name_packet(packet)

Parses the given FXP_NAME packet and returns a hash with one key, :names, which references an array of Name objects.

parse_status_packet(packet)

Parses the given FXP_STATUS packet and returns a hash with one key, :code, which references the status code returned by the server.

read(handle, offset, length)

Sends a FXP_READ packet to the server, requesting that `length` bytes be read from the file identified by `handle`, starting at `offset` bytes within the file. The handle must be one that was returned via a FXP_HANDLE packet. Returns the new packet id.

readdir(handle)

Sends a FXP_READDIR packet to the server, to request a batch of directory name entries in the directory identified by `handle` (which must have been obtained via a FXP_OPENDIR request).

readlink(path)

Not implemented in version 1 of the SFTP protocol. Raises a NotImplementedError if called.

realpath(path)

Sends a FXP_REALPATH packet to the server, to request that the given `path` be canonicalized, taking into account path segments like "..".

remove(filename)

Sends a FXP_REMOTE packet to the server, to request that the given file be deleted from the remote server.

rename(name, new_name, flags=nil)

Not implemented in version 1 of the SFTP protocol. Raises a NotImplementedError if called.

rmdir(path)

Sends a FXP_RMDIR packet to the server, to request that the directory at `path` on the remote server be deleted.

setstat(path, attrs)

Sends a FXP_SETSTAT packet to the server, to update the attributes for the file at the given remote `path` (a string). The `attrs` parameter is a hash that defines the attributes to set.

stat(path, flags=nil)

Sends a FXP_STAT packet to the server, requesting a FXP_ATTR response for the file at the given remote `path` (a string). The `flags` parameter is ignored in this version of the protocol. stat will follow symbolic links; see lstat for a version that will not.

symlink(path, target)

Not implemented in version 1 of the SFTP protocol. Raises a NotImplementedError if called.

unblock(handle, offset, length)

Not implemented in version 1 of the SFTP protocol. Raises a NotImplementedError if called.

version()

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

write(handle, offset, data)

Sends a FXP_WRITE packet to the server, requesting that `data` (a string), be written to the file identified by `handle`, starting at `offset` bytes from the beginning of the file. The handle must be one that was returned via a FXP_HANDLE packet. Returns the new packet id.

### Protected Instance methods

attribute_factory()

Returns the Attributes class used by this version of the protocol (Net::SFTP::Protocol::V01::Attributes, in this case)

name_factory()

Returns the Name class used by this version of the protocol (Net::SFTP::Protocol::V01::Name, in this case)

normalize_open_flags(flags)

Normalizes the given flags parameter, converting it into a combination of IO constants.

not_implemented!(operation)

A helper method for implementing wrappers for operations that are not implemented by the current SFTP protocol version. Simply raises NotImplementedError with a message based on the given operation name.

[Validate]