Class: Net::SFTP::Protocol::V04::Attributes
- Inherits:
-
Net::SFTP::Protocol::V01::Attributes
- Object
- Net::SFTP::Protocol::V01::Attributes
- Net::SFTP::Protocol::V04::Attributes
- Defined in:
- lib/net/sftp/protocol/04/attributes.rb
Overview
A class representing the attributes of a file or directory on the server. It may be used to specify new attributes, or to query existing attributes. This particular class is specific to versions 4 and 5 of the SFTP protocol.
To specify new attributes, just pass a hash as the argument to the constructor. The following keys are supported:
- :type
-
the type of the item (integer, one of the T_ constants)
- :size
-
the size of the item (integer)
- :uid
-
the user-id that owns the file (integer)
- :gid
-
the group-id that owns the file (integer)
- :owner
-
the name of the user that owns the file (string)
- :group
-
the name of the group that owns the file (string)
- :permissions
-
the permissions on the file (integer, e.g. 0755)
- :atime
-
the access time of the file (integer, seconds since epoch)
- :atime_nseconds
-
the nanosecond component of atime (integer)
- :createtime
-
the time at which the file was created (integer, seconds since epoch)
- :createtime_nseconds
-
the nanosecond component of createtime (integer)
- :mtime
-
the modification time of the file (integer, seconds since epoch)
- :mtime_nseconds
-
the nanosecond component of mtime (integer)
- :acl
-
an array of ACL entries for the item
- :extended
-
a hash of name/value pairs identifying extended info
Likewise, when the server sends an Attributes object, all of the above attributes are exposed as methods (though not all will be set with non-nil values from the server).
Direct Known Subclasses
Defined Under Namespace
Classes: ACL
Constant Summary collapse
- F_ACCESSTIME =
0x00000008
- F_CREATETIME =
0x00000010
- F_MODIFYTIME =
0x00000020
- F_ACL =
0x00000040
- F_OWNERGROUP =
0x00000080
- F_SUBSECOND_TIMES =
0x00000100
Constants inherited from Net::SFTP::Protocol::V01::Attributes
Net::SFTP::Protocol::V01::Attributes::F_ACMODTIME, Net::SFTP::Protocol::V01::Attributes::F_EXTENDED, Net::SFTP::Protocol::V01::Attributes::F_PERMISSIONS, Net::SFTP::Protocol::V01::Attributes::F_SIZE, Net::SFTP::Protocol::V01::Attributes::F_UIDGID, Net::SFTP::Protocol::V01::Attributes::T_BLOCK_DEVICE, Net::SFTP::Protocol::V01::Attributes::T_CHAR_DEVICE, Net::SFTP::Protocol::V01::Attributes::T_DIRECTORY, Net::SFTP::Protocol::V01::Attributes::T_FIFO, Net::SFTP::Protocol::V01::Attributes::T_REGULAR, Net::SFTP::Protocol::V01::Attributes::T_SOCKET, Net::SFTP::Protocol::V01::Attributes::T_SPECIAL, Net::SFTP::Protocol::V01::Attributes::T_SYMLINK, Net::SFTP::Protocol::V01::Attributes::T_UNKNOWN
Instance Attribute Summary collapse
-
#acl ⇒ Object
The array of access control entries for this item.
-
#atime_nseconds ⇒ Object
The nanosecond component of the access time.
-
#createtime ⇒ Object
The creation time of the remote item, in seconds since the epoch.
-
#createtime_nseconds ⇒ Object
The nanosecond component of the creation time.
-
#group ⇒ Object
writeonly
The group of the item on the remote server, as a string.
-
#mtime_nseconds ⇒ Object
The nanosecond component of the modification time.
-
#owner ⇒ Object
writeonly
The owner of the item on the remote server, as a string.
-
#type ⇒ Object
The type of the item on the remote server.
Attributes inherited from Net::SFTP::Protocol::V01::Attributes
#atime, #attributes, #extended, #gid, #mtime, #permissions, #size, #uid
Class Method Summary collapse
-
.elements ⇒ Object
The list of supported elements in the attributes structure as defined by v4 of the sftp protocol.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Attributes
constructor
Create a new Attributes instance with the given attributes.
Methods inherited from Net::SFTP::Protocol::V01::Attributes
attr_accessor, attr_writer, #directory?, #file?, from_buffer, #group, #owner, #symbolic_type, #symlink?, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ Attributes
Create a new Attributes instance with the given attributes. The following keys are supported:
- :type
-
the type of the item (integer, one of the T_ constants)
- :size
-
the size of the item (integer)
- :uid
-
the user-id that owns the file (integer)
- :gid
-
the group-id that owns the file (integer)
- :owner
-
the name of the user that owns the file (string)
- :group
-
the name of the group that owns the file (string)
- :permissions
-
the permissions on the file (integer, e.g. 0755)
- :atime
-
the access time of the file (integer, seconds since epoch)
- :atime_nseconds
-
the nanosecond component of atime (integer)
- :createtime
-
the time at which the file was created (integer, seconds since epoch)
- :createtime_nseconds
-
the nanosecond component of createtime (integer)
- :mtime
-
the modification time of the file (integer, seconds since epoch)
- :mtime_nseconds
-
the nanosecond component of mtime (integer)
- :acl
-
an array of ACL entries for the item
- :extended
-
a hash of name/value pairs identifying extended info
All of them default to nil
if omitted, except for type
, which defaults to T_REGULAR.
124 125 126 127 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 124 def initialize(attributes={}) super attributes[:type] ||= T_REGULAR end |
Instance Attribute Details
#acl ⇒ Object
The array of access control entries for this item.
101 102 103 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 101 def acl @acl end |
#atime_nseconds ⇒ Object
The nanosecond component of the access time.
89 90 91 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 89 def atime_nseconds @atime_nseconds end |
#createtime ⇒ Object
The creation time of the remote item, in seconds since the epoch.
92 93 94 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 92 def createtime @createtime end |
#createtime_nseconds ⇒ Object
The nanosecond component of the creation time.
95 96 97 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 95 def createtime_nseconds @createtime_nseconds end |
#group=(value) ⇒ Object (writeonly)
The group of the item on the remote server, as a string.
86 87 88 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 86 def group=(value) @group = value end |
#mtime_nseconds ⇒ Object
The nanosecond component of the modification time.
98 99 100 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 98 def mtime_nseconds @mtime_nseconds end |
#owner=(value) ⇒ Object (writeonly)
The owner of the item on the remote server, as a string.
83 84 85 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 83 def owner=(value) @owner = value end |
#type ⇒ Object
The type of the item on the remote server. Must be one of the T_* constants.
80 81 82 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 80 def type @type end |
Class Method Details
.elements ⇒ Object
The list of supported elements in the attributes structure as defined by v4 of the sftp protocol.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/net/sftp/protocol/04/attributes.rb', line 48 def elements #:nodoc: @elements ||= [ [:type, :byte, 0], [:size, :int64, V01::Attributes::F_SIZE], [:owner, :string, F_OWNERGROUP], [:group, :string, F_OWNERGROUP], [:permissions, :long, V01::Attributes::F_PERMISSIONS], [:atime, :int64, F_ACCESSTIME], [:atime_nseconds, :long, F_ACCESSTIME | F_SUBSECOND_TIMES], [:createtime, :int64, F_CREATETIME], [:createtime_nseconds, :long, F_CREATETIME | F_SUBSECOND_TIMES], [:mtime, :int64, F_MODIFYTIME], [:mtime_nseconds, :long, F_MODIFYTIME | F_SUBSECOND_TIMES], [:acl, :special, F_ACL], [:extended, :special, V01::Attributes::F_EXTENDED] ] end |