Class: FuseFS::PathMapperFS::MNode::XAttr
- Inherits:
-
Object
- Object
- FuseFS::PathMapperFS::MNode::XAttr
- Defined in:
- lib/fusefs/pathmapper.rb
Overview
Merge extended attributes with the ones from the underlying file
Instance Attribute Summary collapse
-
#file_xattr ⇒ Object
readonly
Returns the value of attribute file_xattr.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #additional ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(node) ⇒ XAttr
constructor
A new instance of XAttr.
- #keys ⇒ Object
Constructor Details
#initialize(node) ⇒ XAttr
Returns a new instance of XAttr.
24 25 26 27 |
# File 'lib/fusefs/pathmapper.rb', line 24 def initialize(node) @node = node @file_xattr = ::Xattr.new(node.real_path.to_s) if node.file? && HAS_FFI_XATTR end |
Instance Attribute Details
#file_xattr ⇒ Object (readonly)
Returns the value of attribute file_xattr.
22 23 24 |
# File 'lib/fusefs/pathmapper.rb', line 22 def file_xattr @file_xattr end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
22 23 24 |
# File 'lib/fusefs/pathmapper.rb', line 22 def node @node end |
Instance Method Details
#[](key) ⇒ Object
29 30 31 |
# File 'lib/fusefs/pathmapper.rb', line 29 def [](key) additional[key] || (file_xattr && file_xattr[key]) end |
#[]=(key, value) ⇒ Object
33 34 35 36 |
# File 'lib/fusefs/pathmapper.rb', line 33 def []=(key,value) raise Errno::EACCES if additional.has_key?(key) || node.directory? file_xattr[key] = value if file_xattr end |
#additional ⇒ Object
52 53 54 |
# File 'lib/fusefs/pathmapper.rb', line 52 def additional @node[:xattr] || {} end |
#delete(key) ⇒ Object
38 39 40 41 |
# File 'lib/fusefs/pathmapper.rb', line 38 def delete(key) raise Errno::EACCES if additional.has_key?(key) || node.directory? file_xattr.remove(key) if file_xattr end |
#keys ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/fusefs/pathmapper.rb', line 43 def keys if file_xattr additional.keys + file_xattr.list else additional.keys end end |