# File tar.rb, line 529 529: def initialize( filename, appending, &block ) 530: super() 531: 532: access = ( appending ? ( ::File.exist?( filename ) ? "r+" : "w+" ) : "w" ) 533: 534: @file = ::File.open( filename, access ) 535: @current_entry = nil 536: @total_blocks = 0 537: 538: # if we are appending, look for the last record written to the file (before the 539: # final padding). 540: if appending 541: while not @file.eof? 542: entry = Entry.new( @file ) 543: if entry.nil? 544: @file.pos -= RecordHeader::RECORD_SIZE 545: break 546: else 547: @entries[ entry.name ] = entry 548: end 549: end 550: @total_blocks = @file.pos / RecordHeader::RECORD_SIZE 551: end 552: 553: unless block.nil? 554: yield self 555: close 556: end 557: end