From: Eko Budi Setiyo Date: 2005-02-18T10:22:57+09:00 Subject: Re: question about tar in Ruby --------------020906010004000200010307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Austin Ziegler wrote: >On Fri, 18 Feb 2005 03:58:23 +0900, Ghelani, Vidhi > wrote: > > >>I could not find it . I got to the Ruwiki page and I am lost....can you >>tell me where exactly it is? >> >> > >http://rubyforge.org/frs/?group_id=84&release_id=895 > >-austin > > May be this one will help (part of rubytoday project) ###################################################### # file name tar.rb #ussage tar.rb abc #result abc.tar # require 'zlib' require 'archive/tar/minitar' include Archive::Tar file = ARGV[0].to_s if ARGV[1] != nil tar = File.open(ARGV[1].to_s,'wb') Minitar.pack(file,tar) else tar = File.open(file+'.tar', 'wb') Minitar.pack(file,tar) end ###################################################### #file name zip.tar #usage zip.rb abc.tar #result abc.tar.gz # require 'zlib' file = ARGV[0].to_s local = File.new(file,'rb') if ARGV[1] == nil fileTo = file+'.gz' else fileTo = ARGV[1].to_s end Zlib::GzipWriter.open(fileTo) {|gz| gz.write(local.read) gz.close } local.close ############################################### All the code is part of ruby today project (tested with unit test) If you want more (untar.rb unzip.rb) you can download from http://www.rubytoday.com/download/rubytoday.zip All the unit test is included in the rubytoday.zip if you want to play arrount with it regards Eko http://www.rubytoday.com --------------020906010004000200010307--