Method: Utils#ungzip_file

Defined in:
lib/cryo/utils.rb

#ungzip_file(path) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cryo/utils.rb', line 22

def ungzip_file(path)
  # get a temp file
  tempfile = get_tempfile
  #logger.info "unzipping #{path} to #{tempfile}..."
  
  # stream the gzipped file into an uncompressed file
  Zlib::GzipReader.open(path) do |gz|
    File.open(tempfile,'w') do |open_file|
      # write 1M chunks at a time
      open_file.write gz.read(1024*1024) until gz.eof?
    end
  end
  #logger.info "finished unzipping file"

  # return unzipped file
  tempfile
end