System call using gzip or using rubyzip?


#1

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

require ‘rubygems’
require ‘zip/zip’
require ‘ftools’

File.makedirs(“devlogs_zipped”)
or raise StandardError, “Make dir failed to
~aevrlog/devlogs_zipped!”

if ( array1.length >= 1 )

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

“/cygdrive/c/temp/log/devlogs_zipped/#{file}.#{countr}”`
end
}
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) {
|zipfile|
zipfile.get_output_stream(“first.txt”) { |f| f.puts “Hello from
ZipFile” }
zipfile.mkdir(“a_dir”)
}

thank you


#2

Derek S. wrote:

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

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