Method: Zip::ZipEntry#read_local_entry

Defined in:
lib/ruby_archive/handlers/rubyzip/zip/zip.rb

#read_local_entry(io) ⇒ Object

:nodoc:all



518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 518

def read_local_entry(io)  #:nodoc:all
  @localHeaderOffset = io.tell
  staticSizedFieldsBuf = io.read(LOCAL_ENTRY_STATIC_HEADER_LENGTH)
  unless (staticSizedFieldsBuf.size==LOCAL_ENTRY_STATIC_HEADER_LENGTH)
  raise ZipError, "Premature end of file. Not enough data for zip entry local header"
  end
  
  @header_signature       ,
    @version          ,
  @fstype           ,
  @gp_flags          ,
  @compression_method,
  lastModTime       ,
  lastModDate       ,
  @crc              ,
  @compressed_size   ,
  @size             ,
  nameLength        ,
  extraLength       = staticSizedFieldsBuf.unpack('VCCvvvvVVVvv') 

  unless (@header_signature == LOCAL_ENTRY_SIGNATURE)
  raise ZipError, "Zip local header magic not found at location '#{localHeaderOffset}'"
  end
  set_time(lastModDate, lastModTime)

  
  @name              = io.read(nameLength)
  extra              = io.read(extraLength)

  if (extra && extra.length != extraLength)
  raise ZipError, "Truncated local zip entry header"
  else
    if ZipExtraField === @extra
      @extra.merge(extra)
    else
      @extra = ZipExtraField.new(extra)
    end
  end
  @local_header_size = calculate_local_header_size
end