Class: Omnizip::Formats::Iso::DirectoryRecord
- Inherits:
-
Object
- Object
- Omnizip::Formats::Iso::DirectoryRecord
- Includes:
- Entry
- 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.
- #entry_directory? ⇒ Boolean
- #entry_mtime ⇒ Object
- #entry_name ⇒ Object
- #entry_size ⇒ Object
-
#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.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def data_length @data_length end |
#extended_attr_length ⇒ Object (readonly)
Returns the value of attribute extended_attr_length.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def extended_attr_length @extended_attr_length end |
#file_unit_size ⇒ Object (readonly)
Returns the value of attribute file_unit_size.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def file_unit_size @file_unit_size end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def flags @flags end |
#full_path ⇒ Object
Returns the value of attribute full_path.
11 12 13 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 11 def full_path @full_path end |
#interleave_gap_size ⇒ Object (readonly)
Returns the value of attribute interleave_gap_size.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def interleave_gap_size @interleave_gap_size end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def length @length end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def name @name end |
#recording_date ⇒ Object (readonly)
Returns the value of attribute recording_date.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def recording_date @recording_date end |
#system_use ⇒ Object (readonly)
Returns the value of attribute system_use.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def system_use @system_use end |
#volume_sequence_number ⇒ Object (readonly)
Returns the value of attribute volume_sequence_number.
12 13 14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 12 def volume_sequence_number @volume_sequence_number end |
Class Method Details
.parse(data, offset = 0) ⇒ DirectoryRecord
Parse directory record from binary data
28 29 30 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 28 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
101 102 103 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 101 def current_directory? @name == "\x00" end |
#directory? ⇒ Boolean
Check if entry is a directory
87 88 89 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 87 def directory? @flags.anybits?(Iso::FLAG_DIRECTORY) end |
#entry_directory? ⇒ Boolean
15 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 15 def entry_directory? = directory? |
#entry_mtime ⇒ Object
17 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 17 def entry_mtime = recording_date |
#entry_name ⇒ Object
14 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 14 def entry_name = full_path || name |
#entry_size ⇒ Object
16 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 16 def entry_size = data_length |
#hidden? ⇒ Boolean
Check if entry is hidden
94 95 96 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 94 def hidden? @flags.anybits?(Iso::FLAG_HIDDEN) end |
#mtime ⇒ Time?
Get modification time
122 123 124 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 122 def mtime @recording_date end |
#parent_directory? ⇒ Boolean
Check if this is the parent directory entry
108 109 110 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 108 def parent_directory? @name == "\x01" end |
#parse(data, offset = 0) ⇒ Object
Parse record data
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 76 77 78 79 80 81 82 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 36 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
115 116 117 |
# File 'lib/omnizip/formats/iso/directory_record.rb', line 115 def size @data_length end |