Professional Web Applications Themes

How to use Ruby's zlib? - Ruby

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...

  1. #1

    Default How to use Ruby's zlib?

    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


    Moran, Guest

  2. #2

    Default Re: How to use Ruby's zlib?

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

    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 doentation 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 doentation into RDoc format
    inside the source code? ;)

    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 ...")



    Gavin Guest

  3. #3

    Default Re: How to use Ruby's zlib?

    On Wed, Feb 18, 2004 at 11:47:33PM +0900, Moran, Craig M (BAH) wrote: 

    (untested)

    require 'zip/zipfilesystem'

    filename = "test.zip"
    Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zip|
    zip.file.open("foo.txt", "w") {|f| f.write "file contents"}
    zip.file.open("bar.txt", "w") {|f| f.write "file contents 2"}
    end

    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    How do I type "for i in *.dvi do xdvi $i done" in a GUI?
    -- Discussion in comp.os.linux.misc on the intuitiveness of interfaces


    Mauricio Guest

Similar Threads

  1. Where is zlib-1.2.2 zlib.so?
    By Mark in forum FreeBSD
    Replies: 7
    Last Post: March 22nd, 06:58 PM
  2. Replies: 0
    Last Post: November 1st, 05:21 PM
  3. [ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge
    By guillaume.pierronnet@ratp.fr in forum Ruby
    Replies: 0
    Last Post: August 31st, 11:57 PM
  4. Zlib
    By Andreas Schrafl in forum Ruby
    Replies: 2
    Last Post: July 30th, 02:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139