Forum: Ruby system call using gzip or using rubyzip?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Derek S. (Guest)
on 2009-04-16 06:32
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
Brian C. (Guest)
on 2009-04-16 11:18
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)
This topic is locked and can not be replied to.