# File lib/archive/zip/entry.rb, line 592
    def dump_local_file_record(io, local_file_record_position)
      @local_file_record_position = local_file_record_position
      bytes_written = 0

      # Assume that no trailing data descriptor will be necessary.
      need_trailing_data_descriptor = false
      begin
        io.pos
      rescue Errno::ESPIPE
        # A trailing data descriptor is required for non-seekable IO.
        need_trailing_data_descriptor = true
      end
      if encryption_codec.class == Codec::TraditionalEncryption then
        # HACK:
        # According to the ZIP specification, a trailing data descriptor should
        # only be required when writing to non-seekable IO , but InfoZIP
        # *always* does this when using traditional encryption even though it
        # will also write the data descriptor in the usual place if possible.
        # Failure to emulate InfoZIP in this behavior will prevent InfoZIP
        # compatibility with traditionally encrypted entries.
        need_trailing_data_descriptor = true
        # HACK:
        # The InfoZIP implementation of traditional encryption requires that the
        # the last modified file time be used as part of the encryption header.
        # This is a deviation from the ZIP specification.
        encryption_codec.mtime = mtime
      end

      # Set the general purpose flags.
      general_purpose_flags  = compression_codec.general_purpose_flags
      general_purpose_flags |= encryption_codec.general_purpose_flags
      if need_trailing_data_descriptor then
        general_purpose_flags |= FLAG_DATA_DESCRIPTOR_FOLLOWS
      end

      # Select the minimum ZIP specification version needed to extract this
      # entry.
      version_needed_to_extract = compression_codec.version_needed_to_extract
      if encryption_codec.version_needed_to_extract > version_needed_to_extract then
        version_needed_to_extract = encryption_codec.version_needed_to_extract
      end

      # Write the data.
      bytes_written += io.write(LFH_SIGNATURE)
      extra_field_data = local_extra_field_data
      bytes_written += io.write(
        [
          version_needed_to_extract,
          general_purpose_flags,
          compression_codec.compression_method,
          mtime.to_dos_time.to_i,
          0,
          0,
          0,
          zip_path.length,
          extra_field_data.length
        ].pack('vvvVVVVvv')
      )
      bytes_written += io.write(zip_path)
      bytes_written += io.write(extra_field_data)

      # Pipeline a compressor into an encryptor, write all the file data to the
      # compressor, and get a data descriptor from it.
      encryption_codec.encryptor(io, password) do |e|
        compression_codec.compressor(e) do |c|
          dump_file_data(c)
          c.close(false)
          @data_descriptor = DataDescriptor.new(
            c.data_descriptor.crc32,
            c.data_descriptor.compressed_size + encryption_codec.header_size,
            c.data_descriptor.uncompressed_size
          )
        end
        e.close(false)
      end
      bytes_written += @data_descriptor.compressed_size

      # Write the trailing data descriptor if necessary.
      if need_trailing_data_descriptor then
        bytes_written += io.write(DD_SIGNATURE)
        bytes_written += @data_descriptor.dump(io)
      end

      begin
        # Update the data descriptor located before the compressed data for the
        # entry.
        saved_position = io.pos
        io.pos = @local_file_record_position + 14
        @data_descriptor.dump(io)
        io.pos = saved_position
      rescue Errno::ESPIPE
        # Ignore a failed attempt to update the data descriptor.
      end

      bytes_written
    end