# System call using gzip or using rubyzip?

**URL:** <https://rubytalk.org/t/system-call-using-gzip-or-using-rubyzip/52884>\
**Category:** ruby-talk\
**Created:** [16 April 2009 02:32 UTC](https://rubytalk.org/t/system-call-using-gzip-or-using-rubyzip/52884 "2009-04-16T02:32:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derek\_Smith](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@Derek\_Smith](https://rubytalk.org/u/Derek_Smith)\
**Post date:** [16 April 2009 02:32 UTC](https://rubytalk.org/t/system-call-using-gzip-or-using-rubyzip/52884/1 "2009-04-16T02:32:20Z")

</div>

How do I duplicate this gzip -f call in Ruby?

require 'rubygems'  
require 'zip/zip'  
require 'ftools'

File.makedirs("devlogs\_zipped") \  
&nbsp;&nbsp;&nbsp;&nbsp;or raise StandardError, "Make dir failed to  
~aevrlog/devlogs\_zipped!"

if ( array1.length \>= 1 )

&nbsp;&nbsp;&nbsp;&nbsp;array1.each { |file|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (File.size?(file) \> FSIZE)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;countr+=1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;File.copy(file, "#{file}.#{countr}")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;File.move("#{file}.#{countr}","/cygdrive/c/temp/log/devlogs\_zipped")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`gzip -f  
"/cygdrive/c/temp/log/devlogs\_zipped/#{file}.#{countr}"`  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;}  
end

I played with this code below, but its not what I want, which is to  
create a dir called devlogs\_zipped, then move all dev\* logs to the  
devlogs\_zipped dir, then compress all dev\* logs.

Zip::ZipFile.open("my.zip", Zip::ZipFile::CREATE) {  
&nbsp;&nbsp;&nbsp;\>zipfile\>  
&nbsp;&nbsp;&nbsp;&nbsp;zipfile.get\_output\_stream("first.txt") { |f| f.puts "Hello from  
ZipFile" }  
&nbsp;&nbsp;&nbsp;&nbsp;zipfile.mkdir("a\_dir")  
}

thank you

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [16 April 2009 07:18 UTC](https://rubytalk.org/t/system-call-using-gzip-or-using-rubyzip/52884/2 "2009-04-16T07:18:21Z")

</div>

Derek Smith wrote:

> How do I duplicate this gzip -f call in Ruby?

To gzip individual files, try using zlib (included as a standard  
extension)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
