Class: Net::SFTP::Protocol::V06::Attributes

Inherits:
Net::SFTP::Protocol::V04::Attributes show all
Defined in:
lib/net/sftp/protocol/06/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 6 and higher 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)
  • :allocation_size:: the actual number of bytes that the item uses on disk (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)
  • :ctime:: the time that the file's attributes were last changed (integer)
  • :ctime_nseconds:: the nanosecond component of ctime (integer)
  • :acl:: an array of ACL entries for the item
  • :attrib_bits:: other attributes of the file or directory (as a bit field) (integer)
  • :attrib_bits_valid:: a mask describing which bits in attrib_bits are valid (integer)
  • :text_hint:: whether the file may or may not contain textual data (integer)
  • :mime_type:: the mime type of the file (string)
  • :link_count:: the hard link count of the file (integer)
  • :untranslated_name:: the value of the filename before filename translation was attempted (string)
  • :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).

Constant Summary collapse

F_BITS =
0x00000200
F_ALLOCATION_SIZE =
0x00000400
F_TEXT_HINT =
0x00000800
F_MIME_TYPE =
0x00001000
0x00002000
F_UNTRANSLATED_NAME =
0x00004000
F_CTIME =
0x00008000

Constants inherited from Net::SFTP::Protocol::V04::Attributes

Net::SFTP::Protocol::V04::Attributes::F_ACCESSTIME, Net::SFTP::Protocol::V04::Attributes::F_ACL, Net::SFTP::Protocol::V04::Attributes::F_CREATETIME, Net::SFTP::Protocol::V04::Attributes::F_MODIFYTIME, Net::SFTP::Protocol::V04::Attributes::F_OWNERGROUP, Net::SFTP::Protocol::V04::Attributes::F_SUBSECOND_TIMES

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

Attributes inherited from Net::SFTP::Protocol::V04::Attributes

#acl, #atime_nseconds, #createtime, #createtime_nseconds, #group, #mtime_nseconds, #owner, #type

Attributes inherited from Net::SFTP::Protocol::V01::Attributes

#atime, #attributes, #extended, #gid, #mtime, #permissions, #size, #uid

Class Method Summary collapse

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

#initialize

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

attr_accessor, attr_writer, #directory?, #file?, from_buffer, #group, #initialize, #owner, #symbolic_type, #symlink?, #to_s, #type

Constructor Details

This class inherits a constructor from Net::SFTP::Protocol::V04::Attributes

Instance Attribute Details

#allocation_size ⇒ Object

The size on-disk of the file



80
81
82
# File 'lib/net/sftp/protocol/06/attributes.rb', line 80

def allocation_size
  @allocation_size
end

#attrib_bits ⇒ Object

Other attributes of this file or directory (as a bit field)



89
90
91
# File 'lib/net/sftp/protocol/06/attributes.rb', line 89

def attrib_bits
  @attrib_bits
end

#attrib_bits_valid ⇒ Object

A bit mask describing which bits in #attrib_bits are valid



92
93
94
# File 'lib/net/sftp/protocol/06/attributes.rb', line 92

def attrib_bits_valid
  @attrib_bits_valid
end

#ctime ⇒ Object

The time at which the file's attributes were last changed



83
84
85
# File 'lib/net/sftp/protocol/06/attributes.rb', line 83

def ctime
  @ctime
end

#ctime_nseconds ⇒ Object

The nanosecond component of #ctime



86
87
88
# File 'lib/net/sftp/protocol/06/attributes.rb', line 86

def ctime_nseconds
  @ctime_nseconds
end

The hard link count for the file



101
102
103
# File 'lib/net/sftp/protocol/06/attributes.rb', line 101

def link_count
  @link_count
end

#mime_type ⇒ Object

The mime-type of the file



98
99
100
# File 'lib/net/sftp/protocol/06/attributes.rb', line 98

def mime_type
  @mime_type
end

#text_hint ⇒ Object

Describes whether the file may or may not contain textual data



95
96
97
# File 'lib/net/sftp/protocol/06/attributes.rb', line 95

def text_hint
  @text_hint
end

#untranslated_name ⇒ Object

The value of the file name before filename translation was attempted



104
105
106
# File 'lib/net/sftp/protocol/06/attributes.rb', line 104

def untranslated_name
  @untranslated_name
end

Class Method Details

.elements ⇒ Object

The array of elements that describe this structure, in order. Used when parsing and serializing attribute objects.



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
# File 'lib/net/sftp/protocol/06/attributes.rb', line 52

def self.elements #:nodoc:
  @elements ||= [
    [:type,                :byte,    0],
    [:size,                :int64,   F_SIZE],
    [:allocation_size,     :int64,   F_ALLOCATION_SIZE],
    [:owner,               :string,  F_OWNERGROUP],
    [:group,               :string,  F_OWNERGROUP],
    [:permissions,         :long,    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],
    [:ctime,               :int64,   F_CTIME],
    [:ctime_nseconds,      :long,    F_CTIME | F_SUBSECOND_TIMES],
    [:acl,                 :special, F_ACL],
    [:attrib_bits,         :long,    F_BITS],
    [:attrib_bits_valid,   :long,    F_BITS],
    [:text_hint,           :byte,    F_TEXT_HINT],
    [:mime_type,           :string,  F_MIME_TYPE],
    [:link_count,          :long,    F_LINK_COUNT],
    [:untranslated_name,   :string,  F_UNTRANSLATED_NAME],
    [:extended,            :special, F_EXTENDED]
  ]
end