Class: FuseFS::PathMapperFS::MNode
- Inherits:
-
Object
- Object
- FuseFS::PathMapperFS::MNode
- Defined in:
- lib/fusefs/pathmapper.rb
Overview
Represents a mapped file or directory
Defined Under Namespace
Classes: XAttr
Instance Attribute Summary collapse
-
#files ⇒ Hash<String,MNode>
readonly
List of files in a directory, nil for file nodes.
-
#options ⇒ Hash
readonly
Metadata for this node.
-
#parent ⇒ MNode
readonly
Useful when mapping a file to store attributes against the parent directory.
-
#real_path ⇒ String
readonly
Path to backing file, or nil for directory nodes.
Instance Method Summary collapse
-
#[](key) ⇒ String, ...
Compatibility and convenience method.
-
#[]=(key, value) ⇒ Object
Convenience method to set metadata into #options.
- #deleted ⇒ Object
-
#directory? ⇒ Boolean
True if node represents a directory, otherwise false.
-
#file? ⇒ Boolean
True if node represents a file, otherwise false.
- #init_dir(options) ⇒ Object
-
#root? ⇒ Boolean
True if node is the root directory.
- #updated ⇒ Object
- #xattr ⇒ Object
Instance Attribute Details
#files ⇒ Hash<String,MNode> (readonly)
Returns list of files in a directory, nil for file nodes.
59 60 61 |
# File 'lib/fusefs/pathmapper.rb', line 59 def files @files end |
#options ⇒ Hash (readonly)
Returns metadata for this node.
68 69 70 |
# File 'lib/fusefs/pathmapper.rb', line 68 def @options end |
#parent ⇒ MNode (readonly)
Useful when mapping a file to store attributes against the parent directory
64 65 66 |
# File 'lib/fusefs/pathmapper.rb', line 64 def parent @parent end |
#real_path ⇒ String (readonly)
Returns 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
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 [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) [key]=value end |
#deleted ⇒ Object
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.
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.
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.merge!() self end |
#root? ⇒ Boolean
Returns true if node is the root directory.
110 111 112 |
# File 'lib/fusefs/pathmapper.rb', line 110 def root? @parent.nil? end |
#updated ⇒ Object
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 |