Question about tar in Ruby

Hi,

I could not find it . I got to the Ruwiki page and I am lost....can you
tell me where exactly it is?

Thanx,
Vidhi.

···

-----Original Message-----
From: Austin Ziegler [mailto:halostatue@gmail.com]
Sent: Thursday, February 17, 2005 10:18 AM
To: ruby-talk ML
Subject: Re: question about tar in Ruby

On Fri, 18 Feb 2005 02:44:33 +0900, Ghelani, Vidhi <vidhi.ghelani@intel.com> wrote:

I am trying to package a .tar.gz file using ruby. I have packaged a
.tar file using the same ruby code and it works perfectly fine.

However,

when I use the same code for a .tar.gz file, it give me an error while
trying to open it . It says that this is not a tar file. I know I need
to change something in my ruby code.

There are a few things that I changed i.e. 1) the extension from .tar

to

.tar.gz

However there is a command at the end of the code which does

           Tar -cf #.tar.gz file # a folder which contains the
install and license and everything to do with this file.

Now I know that I need to change the above code, since this is not a

tar

file. Does anyone know wot to do ??

Yes. Look at Archive::Tar::Minitar on RubyForge under the Ruwiki
project.

-austin
--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

http://rubyforge.org/frs/?group_id=84&release_id=895

-austin

···

On Fri, 18 Feb 2005 03:58:23 +0900, Ghelani, Vidhi <vidhi.ghelani@intel.com> wrote:

I could not find it . I got to the Ruwiki page and I am lost....can you
tell me where exactly it is?

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Austin Ziegler wrote:

···

On Fri, 18 Feb 2005 03:58:23 +0900, Ghelani, Vidhi ><vidhi.ghelani@intel.com> 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