class FuseFS::PathMapperFS::MNode

Represents a mapped file or directory

Attributes

files[R]

@return [Hash<String,MNode>] list of files in a directory, nil for file nodes

options[R]

@return [Hash] metadata for this node

parent[R]

Useful when mapping a file to store attributes against the parent directory @return [MNode] parent directory

real_path[R]

@return [String] path to backing file, or nil for directory nodes

Public Class Methods

new(parent_dir,stats) click to toggle source

@!visibility private

# File lib/fusefs/pathmapper.rb, line 76
def initialize(parent_dir,stats)
    @parent = parent_dir
    @files = {}
    @options = {}
    @stats = stats
    @stats_size = 0
    @stats.adjust(0,1)
end

Public Instance Methods

[](key) click to toggle source

Compatibility and convenience method @param [:pm_real_path,String,Symbol] key @return [String] #real_path} if key == :pm_real_path @return [MNode] the node representing the file named key @return [Object] shortcut for {#options

# File lib/fusefs/pathmapper.rb, line 119
def[](key)
    case key
    when :pm_real_path
        real_path
    when String
        files[key]
    else
        options[key]
    end
end
[]=(key,value) click to toggle source

Convenience method to set metadata into {#options}

# File lib/fusefs/pathmapper.rb, line 131
def[]=(key,value)
    options[key]=value
end
deleted() click to toggle source
# File lib/fusefs/pathmapper.rb, line 139
def deleted
    @stats.adjust(-@stats_size,-1)
    @stats_size = 0
end
directory?() click to toggle source

@return [Boolean] true if node represents a directory, otherwise false

# File lib/fusefs/pathmapper.rb, line 105
def directory?
    files && true
end
file?() click to toggle source

@return [Boolean] true if node represents a file, otherwise false

# File lib/fusefs/pathmapper.rb, line 100
def file?
    real_path && true
end
init_dir(options) click to toggle source
# File lib/fusefs/pathmapper.rb, line 94
def init_dir(options)
    @options.merge!(options)
    self
end
init_file(real_path,options) click to toggle source

@!visibility private

# File lib/fusefs/pathmapper.rb, line 86
def init_file(real_path,options)
    @options.merge!(options)
    @real_path = real_path
    @files = nil
    updated
    self
end
root?() click to toggle source

@return [Boolean] true if node is the root directory

# File lib/fusefs/pathmapper.rb, line 110
def root?
    @parent.nil?
end
updated() click to toggle source
# File lib/fusefs/pathmapper.rb, line 144
def updated
    new_size = File.size(real_path)
    @stats.adjust(new_size - @stats_size)
    @stats_size = new_size
end
xattr() click to toggle source
# File lib/fusefs/pathmapper.rb, line 135
def xattr
    @xattr ||= XAttr.new(self)
end