Method: Zip::ZipFile#get_output_stream

Defined in:
lib/pik/contrib/zip/zip.rb

#get_output_stream(entry, &aProc) ⇒ Object

Returns an output stream to the specified entry. If a block is passed the stream object is passed to the block and the stream is automatically closed afterwards just as with ruby’s builtin File.open method.



1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
# File 'lib/pik/contrib/zip/zip.rb', line 1416

def get_output_stream(entry, &aProc)
  newEntry = entry.kind_of?(ZipEntry) ? entry : ZipEntry.new(@name, entry.to_s)
  if newEntry.directory?
  raise ArgumentError,
    "cannot open stream to directory entry - '#{newEntry}'"
  end
  zipStreamableEntry = ZipStreamableStream.new(newEntry)
  @entrySet << zipStreamableEntry
  zipStreamableEntry.get_output_stream(&aProc)      
end