Class: Omnizip::Formats::Iso::DirectoryRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/formats/iso/directory_record.rb

Overview

ISO 9660 Directory Record Represents a file or directory entry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#data_lengthObject (readonly)

Returns the value of attribute data_length.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def data_length
  @data_length
end

#extended_attr_lengthObject (readonly)

Returns the value of attribute extended_attr_length.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def extended_attr_length
  @extended_attr_length
end

#file_unit_sizeObject (readonly)

Returns the value of attribute file_unit_size.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def file_unit_size
  @file_unit_size
end

#flagsObject (readonly)

Returns the value of attribute flags.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def flags
  @flags
end

#full_pathObject

Returns the value of attribute full_path.



9
10
11
# File 'lib/omnizip/formats/iso/directory_record.rb', line 9

def full_path
  @full_path
end

#interleave_gap_sizeObject (readonly)

Returns the value of attribute interleave_gap_size.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def interleave_gap_size
  @interleave_gap_size
end

#lengthObject (readonly)

Returns the value of attribute length.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def length
  @length
end

#locationObject (readonly)

Returns the value of attribute location.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def name
  @name
end

#recording_dateObject (readonly)

Returns the value of attribute recording_date.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def recording_date
  @recording_date
end

#system_useObject (readonly)

Returns the value of attribute system_use.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def system_use
  @system_use
end

#volume_sequence_numberObject (readonly)

Returns the value of attribute volume_sequence_number.



10
11
12
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10

def volume_sequence_number
  @volume_sequence_number
end

Class Method Details

.parse(data, offset = 0) ⇒ DirectoryRecord

Parse directory record from binary data

Parameters:

  • data (String)

    Binary record data

  • offset (Integer) (defaults to: 0)

    Offset in data to start parsing

Returns:



21
22
23
# File 'lib/omnizip/formats/iso/directory_record.rb', line 21

def self.parse(data, offset = 0)
  new.tap { |record| record.parse(data, offset) }
end

Instance Method Details

#current_directory?Boolean

Check if this is the current directory entry

Returns:

  • (Boolean)

    true if current directory



94
95
96
# File 'lib/omnizip/formats/iso/directory_record.rb', line 94

def current_directory?
  @name == "\x00"
end

#directory?Boolean

Check if entry is a directory

Returns:

  • (Boolean)

    true if directory



80
81
82
# File 'lib/omnizip/formats/iso/directory_record.rb', line 80

def directory?
  @flags.anybits?(Iso::FLAG_DIRECTORY)
end

#hidden?Boolean

Check if entry is hidden

Returns:

  • (Boolean)

    true if hidden



87
88
89
# File 'lib/omnizip/formats/iso/directory_record.rb', line 87

def hidden?
  @flags.anybits?(Iso::FLAG_HIDDEN)
end

#mtimeTime?

Get modification time

Returns:

  • (Time, nil)

    Modification time



115
116
117
# File 'lib/omnizip/formats/iso/directory_record.rb', line 115

def mtime
  @recording_date
end

#parent_directory?Boolean

Check if this is the parent directory entry

Returns:

  • (Boolean)

    true if parent directory



101
102
103
# File 'lib/omnizip/formats/iso/directory_record.rb', line 101

def parent_directory?
  @name == "\x01"
end

#parse(data, offset = 0) ⇒ Object

Parse record data

Parameters:

  • data (String)

    Binary data

  • offset (Integer) (defaults to: 0)

    Starting offset



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/omnizip/formats/iso/directory_record.rb', line 29

def parse(data, offset = 0)
  # Byte 0: Length of directory record
  @length = data.getbyte(offset)
  return if @length.zero? # Padding

  # Byte 1: Extended attribute record length
  @extended_attr_length = data.getbyte(offset + 1)

  # Bytes 2-9: Location of extent (both-endian)
  @location = data[offset + 2, 4].unpack1("V")

  # Bytes 10-17: Data length (both-endian)
  @data_length = data[offset + 10, 4].unpack1("V")

  # Bytes 18-24: Recording date and time
  @recording_date = parse_record_datetime(data[offset + 18, 7])

  # Byte 25: File flags
  @flags = data.getbyte(offset + 25)

  # Byte 26: File unit size (for interleaved files)
  @file_unit_size = data.getbyte(offset + 26)

  # Byte 27: Interleave gap size
  @interleave_gap_size = data.getbyte(offset + 27)

  # Bytes 28-31: Volume sequence number (both-endian)
  @volume_sequence_number = data[offset + 28, 2].unpack1("v")

  # Byte 32: Length of file identifier
  name_length = data.getbyte(offset + 32)

  # Bytes 33+: File identifier
  @name = data[offset + 33, name_length]

  # Parse file identifier
  parse_name

  # System Use field (Rock Ridge extensions, etc.)
  # Located after name and padding
  su_offset = offset + 33 + name_length
  su_offset += 1 if name_length.even? # Padding byte

  return unless su_offset < offset + @length

  @system_use = data[su_offset, offset + @length - su_offset]
end

#sizeInteger

Get file size

Returns:

  • (Integer)

    Size in bytes



108
109
110
# File 'lib/omnizip/formats/iso/directory_record.rb', line 108

def size
  @data_length
end