Class: Iso9660::DirectoryEntry
- Inherits:
-
Object
- Object
- Iso9660::DirectoryEntry
- Defined in:
- lib/fs/iso9660/directory_entry.rb
Constant Summary collapse
- DIR_ENT =
BinaryStruct.new([ 'C', 'length', # Bytes, must be even. 'C', 'ext_attr_length', # Sectors. 'L', 'extentLE', # First sector of data. 'L', 'extentBE', 'L', 'sizeLE', # Size of data in bytes. 'L', 'sizeBE', 'a7', 'date', # ISODATE 'C', 'flags', # Flags, see FB_ above. 'C', 'file_unit_size', # For interleaved files: not supported. 'C', 'interleave', # Not supported. 'S', 'vol_seq_numLE', # Not used. 'S', 'vol_seq_numBE', 'C', 'name_len', # Bytes. ])
- SIZEOF_DIR_ENT =
Here follows a name. Character set is limited ASCII. Here follows an optional padding byte (if name_len is even). Here follows unspecified extra data, size is included in member length.
DIR_ENT.size
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#myEnt ⇒ Object
readonly
Returns the value of attribute myEnt.
Instance Method Summary collapse
- #checkExt(sym) ⇒ Object
- #dump ⇒ Object
- #fileSize ⇒ Object
- #fileStart ⇒ Object
-
#initialize(data, suff, flags = EXT_NONE) ⇒ DirectoryEntry
constructor
A new instance of DirectoryEntry.
- #isDir? ⇒ Boolean
- #isFile? ⇒ Boolean
- #isSymLink? ⇒ Boolean
- #name ⇒ Object
- #processRockRidge ⇒ Object
- #sua ⇒ Object
Constructor Details
#initialize(data, suff, flags = EXT_NONE) ⇒ DirectoryEntry
Returns a new instance of DirectoryEntry.
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 |
# File 'lib/fs/iso9660/directory_entry.rb', line 47 def initialize(data, suff, flags = EXT_NONE) raise "Data is nil." if data.nil? @suff = suff # Get data. @de = DIR_ENT.decode(data) @length = @de['length'] @myEnt = data[0...@length] @date = Util.IsoShortToRubyDate(@de['date']) offset = SIZEOF_DIR_ENT len = @de['name_len'] if len > 0 name = data[offset...(offset + len)] # Convert 00 to dot and 01 to dotdot. if len == 1 && (name[0] == 0 || name[0] == 1) name = "." if name[0] == 0 name = ".." if name[0] == 1 else name.Ucs2ToAscii! if flags & EXT_JOLIET == EXT_JOLIET end offset += len offset += 1 if len & 1 == 0 && (flags & EXT_JOLIET == 0) # Cheap test for even/odd. end @de['name'] = name @de['sua'] = data[offset...@de['length'] - 1] if offset < @de['length'] processRockRidge if flags & EXT_ROCKRIDGE == EXT_ROCKRIDGE end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
45 46 47 |
# File 'lib/fs/iso9660/directory_entry.rb', line 45 def date @date end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
45 46 47 |
# File 'lib/fs/iso9660/directory_entry.rb', line 45 def length @length end |
#myEnt ⇒ Object (readonly)
Returns the value of attribute myEnt.
45 46 47 |
# File 'lib/fs/iso9660/directory_entry.rb', line 45 def myEnt @myEnt end |
Instance Method Details
#checkExt(sym) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/fs/iso9660/directory_entry.rb', line 109 def checkExt(sym) return nil if @rr.nil? res = nil @rr.extensions.each do |extension| ext = extension.ext begin res = ext.send(sym) rescue break unless res.nil? end end res end |
#dump ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/fs/iso9660/directory_entry.rb', line 131 def dump out = "" out << "Length : #{@de['length']}\n" out << "Attr len: #{@de['ext_attr_length']} (sectors)\n" out << "Data sec: #{@de["extent#{@suff}"]}\n" out << "Size : #{@de["size#{@suff}"]}\n" out << "Date : #{@date}\n" out << "Flags : 0x#{'%02x' % @de['flags']}\n" out << "Name len: #{@de['name_len']}\n" out << "Name : #{@de['name']}\n" if @de['sua'] out << "System U:\n" out << @de['sua'].hex_dump end out end |
#fileSize ⇒ Object
87 88 89 90 91 92 |
# File 'lib/fs/iso9660/directory_entry.rb', line 87 def fileSize return @de["size#{@suff}"] if @rr.nil? size = checkExt("linkData") return size.size unless size.nil? @de["size#{@suff}"] end |
#fileStart ⇒ Object
83 84 85 |
# File 'lib/fs/iso9660/directory_entry.rb', line 83 def fileStart @de["extent#{@suff}"] end |
#isDir? ⇒ Boolean
98 99 100 |
# File 'lib/fs/iso9660/directory_entry.rb', line 98 def isDir? @de['flags'] & FB_DIRECTORY == FB_DIRECTORY end |
#isFile? ⇒ Boolean
94 95 96 |
# File 'lib/fs/iso9660/directory_entry.rb', line 94 def isFile? @de['flags'] & FB_DIRECTORY == 0 end |
#isSymLink? ⇒ Boolean
102 103 104 105 106 107 |
# File 'lib/fs/iso9660/directory_entry.rb', line 102 def isSymLink? return false if @rr.nil? isLink = checkExt("linkData") return true unless isLink.nil? false end |
#name ⇒ Object
75 76 77 |
# File 'lib/fs/iso9660/directory_entry.rb', line 75 def name @de['name'] end |
#processRockRidge ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/fs/iso9660/directory_entry.rb', line 123 def processRockRidge return if length == 0 @rr = RockRidge.new(self) # Check for alternate name. new_name = checkExt("name") @de['name'] = new_name unless new_name.nil? end |
#sua ⇒ Object
79 80 81 |
# File 'lib/fs/iso9660/directory_entry.rb', line 79 def sua @de['sua'] end |