Class: NTFS::DirectoryIndexNode
- Inherits:
-
Object
- Object
- NTFS::DirectoryIndexNode
- Defined in:
- lib/fs/ntfs/directory_index_node.rb
Constant Summary collapse
- IN_HAS_CHILD =
0x00000001- IN_LAST_ENTRY =
0x00000002
Instance Attribute Summary collapse
-
#afn ⇒ Object
readonly
Returns the value of attribute afn.
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#contentLen ⇒ Object
readonly
Returns the value of attribute contentLen.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#mftEntry ⇒ Object
readonly
Returns the value of attribute mftEntry.
-
#refMft ⇒ Object
readonly
Returns the value of attribute refMft.
Class Method Summary collapse
Instance Method Summary collapse
-
#dump ⇒ Object
Dumps object.
-
#hasChild? ⇒ Boolean
Return true if has children.
-
#initialize(buf) ⇒ DirectoryIndexNode
constructor
A new instance of DirectoryIndexNode.
-
#isDir? ⇒ Boolean
If content is 0, then obviously not a directory.
-
#isLast? ⇒ Boolean
Return true if this is the last entry.
-
#name ⇒ Object
Return file name (if resolved).
-
#namespace ⇒ Object
Return namespace.
-
#resolve(bs) ⇒ Object
Resolves this node’s file reference.
-
#to_s ⇒ Object
String rep.
Constructor Details
#initialize(buf) ⇒ DirectoryIndexNode
Returns a new instance of DirectoryIndexNode.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 34 def initialize(buf) raise "MIQ(NTFS::DirectoryIndexNode.initialize) Nil buffer" if buf.nil? buf = buf.read(buf.length) if buf.kind_of?(DataRun) # Decode the directory index node structure. @din = DIR_INDEX_NODE.decode(buf) # Get accessor data. @mftEntry = nil @refMft = NTFS::Utils.MkRef(@din['mft_ref']) @length = @din['length'] @contentLen = @din['content_len'] @flags = @din['flags'] # If there's a $FILE_NAME attrib get it. @afn = FileName.new(buf[SIZEOF_DIR_INDEX_NODE, buf.size]) if @contentLen > 0 # If there's a child node VCN get it. if NTFS::Utils.gotBit?(@flags, IN_HAS_CHILD) # Child node VCN is located 8 bytes before 'length' bytes. # NOTE: If the node has 0 contents, it's offset 16. @child = buf[@contentLen == 0 ? 16 : @length - 8, 8].unpack('Q')[0] end end |
Instance Attribute Details
#afn ⇒ Object (readonly)
Returns the value of attribute afn.
20 21 22 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 20 def afn @afn end |
#child ⇒ Object (readonly)
Returns the value of attribute child.
20 21 22 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 20 def child @child end |
#contentLen ⇒ Object (readonly)
Returns the value of attribute contentLen.
20 21 22 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 20 def contentLen @contentLen end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
20 21 22 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 20 def flags @flags end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
20 21 22 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 20 def length @length end |
#mftEntry ⇒ Object (readonly)
Returns the value of attribute mftEntry.
20 21 22 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 20 def mftEntry @mftEntry end |
#refMft ⇒ Object (readonly)
Returns the value of attribute refMft.
20 21 22 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 20 def refMft @refMft end |
Class Method Details
.nodeFactory(buf) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 22 def self.nodeFactory(buf) nodes = [] loop do node = DirectoryIndexNode.new(buf) buf = buf[node.length..-1] nodes << node break if node.isLast? end nodes end |
Instance Method Details
#dump ⇒ Object
Dumps object.
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 99 def dump out = "\#<#{self.class}:0x#{'%08x' % object_id}>\n" out << " Mft Ref : seq #{@refMft[0]}, entry #{@refMft[1]}\n" out << " Length : #{@length}\n" out << " Content : #{@contentLen}\n" out << " Flags : 0x#{'%08x' % @flags}\n" out << @afn.dump if @contentLen > 0 out << " Child ref: #{@child}\n" if NTFS::Utils.gotBit?(@flags, IN_HAS_CHILD) out << "---\n" end |
#hasChild? ⇒ Boolean
Return true if has children.
74 75 76 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 74 def hasChild? NTFS::Utils.gotBit?(@flags, IN_HAS_CHILD) end |
#isDir? ⇒ Boolean
If content is 0, then obviously not a directory.
84 85 86 87 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 84 def isDir? return false if @contentLen == 0 @mftEntry.isDir? end |
#isLast? ⇒ Boolean
Return true if this is the last entry.
79 80 81 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 79 def isLast? NTFS::Utils.gotBit?(@flags, IN_LAST_ENTRY) end |
#name ⇒ Object
Return file name (if resolved).
64 65 66 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 64 def name @afn.nil? ? nil : @afn.name end |
#namespace ⇒ Object
Return namespace.
69 70 71 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 69 def namespace @afn.nil? ? nil : @afn.namespace end |
#resolve(bs) ⇒ Object
Resolves this node’s file reference.
90 91 92 93 94 95 96 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 90 def resolve(bs) if @contentLen > 0 @mftEntry = bs.mftEntry(@refMft[1]) raise "MIQ(NTFS::DirectoryIndexNode.resolve) Stale reference: #{inspect}" if @refMft[0] != @mftEntry.sequenceNum end @mftEntry end |
#to_s ⇒ Object
String rep.
59 60 61 |
# File 'lib/fs/ntfs/directory_index_node.rb', line 59 def to_s "\#<#{self.class}:0x#{'%08x' % object_id} name='#{name}'>" end |