Class: Iso9660::Directory
- Inherits:
-
Object
- Object
- Iso9660::Directory
- Defined in:
- lib/fs/iso9660/directory.rb
Constant Summary collapse
- FE_DIR =
Find entry flags.
0
- FE_FILE =
1
- FE_EITHER =
2
- SUSP =
System Use Sharing Protocol header (for Rock Ridge in this implementation).
BinaryStruct.new([ 'a2', 'signature', 'C', 'len', 'C', 'version', 'n', 'check', 'C', 'skip_bytes' ])
- SUSP_SIGNATURE =
"SP"
- SUSP_SIZE =
7
- SUSP_VERSION =
1
- SUSP_CHECK_WORD =
0xbeef
Instance Attribute Summary collapse
-
#myEnt ⇒ Object
readonly
Returns the value of attribute myEnt.
-
#susp ⇒ Object
readonly
Returns the value of attribute susp.
Instance Method Summary collapse
- #checkRockRidge(de) ⇒ Object
- #findEntry(name, _flags = FE_EITHER) ⇒ Object
- #getDirData ⇒ Object
- #globEntries ⇒ Object
- #globNames ⇒ Object
-
#initialize(bs, thisEntry) ⇒ Directory
constructor
A new instance of Directory.
Constructor Details
#initialize(bs, thisEntry) ⇒ Directory
Returns a new instance of Directory.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fs/iso9660/directory.rb', line 26 def initialize(bs, thisEntry) raise "Boot sector is nil." if bs.nil? raise "No directory entry specified." if thisEntry.nil? raise "Given entry is not a DirectoryEntry" if thisEntry.class.to_s != "Iso9660::DirectoryEntry" @bs = bs @myEnt = thisEntry @data = getDirData # Check for RockRidge extensions. @susp = checkRockRidge(DirectoryEntry.new(@data, @bs.suff)) end |
Instance Attribute Details
#myEnt ⇒ Object (readonly)
Returns the value of attribute myEnt.
24 25 26 |
# File 'lib/fs/iso9660/directory.rb', line 24 def myEnt @myEnt end |
#susp ⇒ Object (readonly)
Returns the value of attribute susp.
24 25 26 |
# File 'lib/fs/iso9660/directory.rb', line 24 def susp @susp end |
Instance Method Details
#checkRockRidge(de) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fs/iso9660/directory.rb', line 78 def checkRockRidge(de) if de.sua susp = SUSP.decode(de.sua) return nil if susp['signature'] != SUSP_SIGNATURE return nil if susp['len'] != SUSP_SIZE return nil if susp['check'] != SUSP_CHECK_WORD raise "System Use Sharing Protocol version mismatch" if susp['version'] != SUSP_VERSION return susp end nil end |
#findEntry(name, _flags = FE_EITHER) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/fs/iso9660/directory.rb', line 49 def findEntry(name, _flags = FE_EITHER) # TODO: enable flags globEntries.each do |de| return de if de.name == name # Joliet & RR are case sensitive. return de if de.name == name.upcase # ISO 9660 is ucase only. end nil end |
#getDirData ⇒ Object
39 40 41 |
# File 'lib/fs/iso9660/directory.rb', line 39 def getDirData @bs.getSectors(@myEnt.fileStart, @myEnt.fileSize / @bs.sectorSize) end |
#globEntries ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fs/iso9660/directory.rb', line 58 def globEntries # Prep flag bits. flags = EXT_NONE flags |= EXT_JOLIET if @bs.isJoliet? flags |= EXT_ROCKRIDGE if @susp # Glob entries. entries = [] offset = 0 loop do de = DirectoryEntry.new(@data[offset..-1], @bs.suff, flags) break if de.length == 0 entries << de # Debugging only. # puts "#{de.dump}\n" offset += de.length end entries end |
#globNames ⇒ Object
43 44 45 46 47 |
# File 'lib/fs/iso9660/directory.rb', line 43 def globNames names = [] globEntries.each { |de| names << de.name } names end |