Class: Resilience::FSDir::FileEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/resilience/fs_dir/file_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ FileEntry

Returns a new instance of FileEntry.



20
21
22
23
24
25
26
# File 'lib/resilience/fs_dir/file_entry.rb', line 20

def initialize(args={})
  @prefix   = args[:prefix]
  @name     = args[:name]
  @metadata = args[:metadata]
  @record   = args[:record]
  parse_attrs
end

Instance Attribute Details

#metadataObject

Returns the value of attribute metadata.



12
13
14
# File 'lib/resilience/fs_dir/file_entry.rb', line 12

def 
  @metadata
end

#metadata_attrsObject

known metadata attributes



18
19
20
# File 'lib/resilience/fs_dir/file_entry.rb', line 18

def 
  @metadata_attrs
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/resilience/fs_dir/file_entry.rb', line 11

def name
  @name
end

#prefixObject

Returns the value of attribute prefix.



10
11
12
# File 'lib/resilience/fs_dir/file_entry.rb', line 10

def prefix
  @prefix
end

#recordObject

metadata record



15
16
17
# File 'lib/resilience/fs_dir/file_entry.rb', line 15

def record
  @record
end

Instance Method Details

#fullnameObject



28
29
30
# File 'lib/resilience/fs_dir/file_entry.rb', line 28

def fullname
  "#{prefix}\\#{name}"
end

#parse_attrsObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/resilience/fs_dir/file_entry.rb', line 36

def parse_attrs
    = @metadata.unpack('C*')
   = @metadata.unpack('L*')
  attr1_length    = [0]
  attr1_dwords    = attr1_length/4
  attr2_length    = [attr1_dwords]
  attr2_dwords    = attr2_length/4
  attr3_length    = [attr1_dwords + attr2_dwords]
  # there may be other attrs after this point...

  attr1 = [0..attr1_length]
  attr2 = [attr1_length..attr1_length+attr2_length]
  attr3 = [attr1_length+attr2_length..attr1_length+attr2_length+attr3_length]
  @metadata_attrs = [attr1, attr2, attr3]
end

#total_offsetObject



32
33
34
# File 'lib/resilience/fs_dir/file_entry.rb', line 32

def total_offset
  image.offset + record.attribute.pos
end