How to use Ruby's zlib?


(Moran, Craig M (BAH)) #1

I would like to add or move a file to a pre-existing gzipped file. Nobu
tipped me off to the fact that Ruby has built in zlib methods. I can’t,
however, find any good examples of what I want to do. Specifically, I’d
like to move all *.log files in a directory to a file named Archived.gz.
Help please?
Kindest Regards-
Craig


(Gavin Sinclair) #2

I’d love to say I knew how, but I don’t. If you take a look at

http://www.ruby-doc.org/stdlib/libdoc/zlib/rdoc/index.html

you can see what classes and methods are implemented. With
experimentation, you’ll probably get somewhere.

Ooops, just looked and saw that there is some documentation alongside
the source code: ext/zlib/doc/zlib.rd. That means it’s probably on
the web somewhere; try Google.

Any volunteers for converting this RD documentation into RDoc format
inside the source code? :wink:

Cheers,
Gavin

PS. GZip compresses single files, unlike ZIP, which creates compressed
archives. So getting a bunch of files into a .gz file is not feasible
without using TAR. I don’t know how people might go about creating
compressed archives with Ruby. I use: system(“tar zcvf …”)

···

On Thursday, February 19, 2004, 12:24:40 AM, Craig wrote:

I would like to add or move a file to a pre-existing gzipped file. Nobu
tipped me off to the fact that Ruby has built in zlib methods. I can’t,
however, find any good examples of what I want to do. Specifically, I’d
like to move all *.log files in a directory to a file named Archived.gz.
Help please?
Kindest Regards-
Craig