Class: FuseFS::PathMapperFS::MNode

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

Overview

Represents a mapped file or directory

Defined Under Namespace

Classes: XAttr

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filesHash<String,MNode> (readonly)

Returns list of files in a directory, nil for file nodes.

Returns:

  • (Hash<String,MNode>)

    list of files in a directory, nil for file nodes



59
60
61
# File 'lib/fusefs/pathmapper.rb', line 59

def files
  @files
end

#optionsHash (readonly)

Returns metadata for this node.

Returns:

  • (Hash)

    metadata for this node



68
69
70
# File 'lib/fusefs/pathmapper.rb', line 68

def options
  @options
end

#parentMNode (readonly)

Useful when mapping a file to store attributes against the parent directory

Returns:

  • (MNode)

    parent directory



64
65
66
# File 'lib/fusefs/pathmapper.rb', line 64

def parent
  @parent
end

#real_pathString (readonly)

Returns path to backing file, or nil for directory nodes.

Returns:

  • (String)

    path to backing file, or nil for directory nodes



72
73
74
# File 'lib/fusefs/pathmapper.rb', line 72

def real_path
  @real_path
end

Instance Method Details

#[](key) ⇒ String, ...

Compatibility and convenience method

Parameters:

  • key (:pm_real_path, String, Symbol)

Returns:

  • (String)

    #real_path if key == :pm_real_path

  • (MNode)

    the node representing the file named key

  • (Object)

    shortcut for #options



119
120
121
122
123
124
125
126
127
128
# 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) ⇒ Object

Convenience method to set metadata into #options



131
132
133
# File 'lib/fusefs/pathmapper.rb', line 131

def[]=(key,value)
    options[key]=value
end

#deletedObject



139
140
141
142
# File 'lib/fusefs/pathmapper.rb', line 139

def deleted
    @stats.adjust(-@stats_size,-1)
    @stats_size = 0
end

#directory?Boolean

Returns true if node represents a directory, otherwise false.

Returns:

  • (Boolean)

    true if node represents a directory, otherwise false



105
106
107
# File 'lib/fusefs/pathmapper.rb', line 105

def directory?
    files && true
end

#file?Boolean

Returns true if node represents a file, otherwise false.

Returns:

  • (Boolean)

    true if node represents a file, otherwise false



100
101
102
# File 'lib/fusefs/pathmapper.rb', line 100

def file?
    real_path && true
end

#init_dir(options) ⇒ Object



94
95
96
97
# File 'lib/fusefs/pathmapper.rb', line 94

def init_dir(options)
    @options.merge!(options)
    self
end

#root?Boolean

Returns true if node is the root directory.

Returns:

  • (Boolean)

    true if node is the root directory



110
111
112
# File 'lib/fusefs/pathmapper.rb', line 110

def root?
    @parent.nil?
end

#updatedObject



144
145
146
147
148
# 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

#xattrObject



135
136
137
# File 'lib/fusefs/pathmapper.rb', line 135

def xattr
    @xattr ||= XAttr.new(self)
end