system call using gzip or using rubyzip?

D

Derek Smith

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top