Class: OdinFlex::AR
Defined Under Namespace
Classes: Info
Constant Summary collapse
- HEADER_LENGTH =
File Identifier
16 + # File Identifier 12 + # File modification timestamp 6 + # Owner ID 6 + # Group ID 8 + # File Mode 10 + # File size in bytes 2
- AR_HEADER =
Ending characters
"!<arch>\n"
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(fd) ⇒ AR
constructor
A new instance of AR.
Constructor Details
#initialize(fd) ⇒ AR
Returns a new instance of AR.
23 24 25 26 |
# File 'lib/odinflex/ar.rb', line 23 def initialize fd @fd = fd @pos = fd.pos end |
Class Method Details
Instance Method Details
#each ⇒ Object
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 |
# File 'lib/odinflex/ar.rb', line 30 def each @fd.seek @pos, IO::SEEK_SET header = @fd.read(AR_HEADER.length) raise "Wrong Header" unless header == AR_HEADER loop do break if @fd.eof? identifier, , owner, group, mode, size, ending = @fd.read(HEADER_LENGTH).unpack('A16A12A6A6A8A10A2') raise "wrong ending #{ending}" unless ending.bytes == [0x60, 0x0A] pos = @fd.pos # Assume BSD for now fname_len = identifier[/\d+$/].to_i filename = @fd.read(fname_len).unpack1('A*') info = Info.new filename, , owner, group, mode, size.to_i - fname_len, @fd.pos yield info @fd.seek size.to_i + pos, IO::SEEK_SET end end |