Class: Iso9660::RockRidge

Inherits:
Object
  • Object
show all
Defined in:
lib/fs/iso9660/rock_ridge.rb

Overview

class Extension

Constant Summary collapse

SUSP_SIZE =
7
CONTINUE =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(de, suff) ⇒ RockRidge

Returns a new instance of RockRidge.



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/fs/iso9660/rock_ridge.rb', line 285

def initialize(de, suff)
  raise "No DirectoryEntry specified." if de.nil?
  raise "The specified DirectoryEntry has no System Use Area." if de.sua.nil?

  # Root directories need to skip SUSP header.
  offset = de.name == "." ? SUSP_SIZE : 0

  # Get the RR header from the DirectoryEntry & verify.
  @header = RR_HEADER.decode(de.sua[offset..-1])
  raise "This is not a Rock Ridge extension record" if @header['signature'] != RR_SIGNATURE

  # Loop through extensions.
  offset += RR_HEADER_SIZE
  @extensions = []
  loop do
    # puts "Extension data:
    # de.sua[offset..-1].hex_dump(:obj => STDOUT, :meth => :puts, :newline => false)
    # puts "\n\n"
    ext = Extension.new(de.sua[offset..-1], suff)
    @extensions << ext
    offset += ext.length
    break if offset >= de.sua.length
  end

  # Handle continuations.
  0.upto(@extensions.size - 1) do |idx|
    obj = @extensions[idx]
    next if obj.nil?

    # TODO: Simplify this - the meat of all extensions is .data
    if obj.flags & CONTINUE
      if obj.kind_of?(AlternateName)
        obj.name += @extensions[idx + 1].name
        @extensions[idx + 1] = nil
      end
      if obj.kind_of?(SymbolicLink)
        obj.linkData += @extensions[idx + 1].linkData
        @extensions[idx + 1] = nil
      end
    end
  end
  @extensions.delete(nil)
end

Instance Attribute Details

#extensionsObject (readonly)

Returns the value of attribute extensions.



283
284
285
# File 'lib/fs/iso9660/rock_ridge.rb', line 283

def extensions
  @extensions
end