Class: Omnizip::Formats::Iso::DirectoryRecord
- Inherits:
-
Object
- Object
- Omnizip::Formats::Iso::DirectoryRecord
- Defined in:
- lib/omnizip/formats/iso/directory_record.rb
Overview
ISO 9660 Directory Record Represents a file or directory entry
Instance Attribute Summary collapse
-
#data_length ⇒ Object
readonly
Returns the value of attribute data_length.
-
#extended_attr_length ⇒ Object
readonly
Returns the value of attribute extended_attr_length.
-
#file_unit_size ⇒ Object
readonly
Returns the value of attribute file_unit_size.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#full_path ⇒ Object
Returns the value of attribute full_path.
-
#interleave_gap_size ⇒ Object
readonly
Returns the value of attribute interleave_gap_size.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#recording_date ⇒ Object
readonly
Returns the value of attribute recording_date.
-
#system_use ⇒ Object
readonly
Returns the value of attribute system_use.
-
#volume_sequence_number ⇒ Object
readonly
Returns the value of attribute volume_sequence_number.
Class Method Summary collapse
-
.parse(data, offset = 0) ⇒ DirectoryRecord
Parse directory record from binary data.
Instance Method Summary collapse
-
#current_directory? ⇒ Boolean
Check if this is the current directory entry.
-
#directory? ⇒ Boolean
Check if entry is a directory.
-
#hidden? ⇒ Boolean
Check if entry is hidden.
-
#mtime ⇒ Time?
Get modification time.
-
#parent_directory? ⇒ Boolean
Check if this is the parent directory entry.
-
#parse(data, offset = 0) ⇒ Object
Parse record data.
-
#size ⇒ Integer
Get file size.
Instance Attribute Details
#data_length ⇒ Object (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_length ⇒ Object (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_size ⇒ Object (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 |
#flags ⇒ Object (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_path ⇒ Object
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_size ⇒ Object (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 |
#length ⇒ Object (readonly)
Returns the value of attribute length.
10 11 12 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10 def length @length end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
10 11 12 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 10 def location @location end |
#name ⇒ Object (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_date ⇒ Object (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_use ⇒ Object (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_number ⇒ Object (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
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
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
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
87 88 89 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 87 def hidden? @flags.anybits?(Iso::FLAG_HIDDEN) end |
#mtime ⇒ Time?
Get 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
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
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 |
#size ⇒ Integer
Get file size
108 109 110 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 108 def size @data_length end |