Class: FuseFS::PathMapperFS::MNode::XAttr

Inherits:
Object
  • Object
show all
Defined in:
lib/fusefs/pathmapper.rb

Overview

Merge extended attributes with the ones from the underlying file

Instance Attribute Summary collapse

Instance Method Summary collapse

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_xattrObject (readonly)

Returns the value of attribute file_xattr.



22
23
24
# File 'lib/fusefs/pathmapper.rb', line 22

def file_xattr
  @file_xattr
end

#nodeObject (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

Raises:

  • (Errno::EACCES)


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

#additionalObject



52
53
54
# File 'lib/fusefs/pathmapper.rb', line 52

def additional
    @node[:xattr] || {}
end

#delete(key) ⇒ Object

Raises:

  • (Errno::EACCES)


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

#keysObject



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