ruby-changes:18373
From: naruse <ko1@a...>
Date: Mon, 27 Dec 2010 10:36:23 +0900 (JST)
Subject: [ruby-changes:18373] Ruby:r30396 (trunk): Update rdoc of zlib.
naruse 2010-12-27 10:36:16 +0900 (Mon, 27 Dec 2010) New Revision: 30396 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30396 Log: Update rdoc of zlib. Add description about gzip(1) compatible output. Modified files: trunk/ext/zlib/zlib.c Index: ext/zlib/zlib.c =================================================================== --- ext/zlib/zlib.c (revision 30395) +++ ext/zlib/zlib.c (revision 30396) @@ -2852,7 +2852,7 @@ * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should * be used with an instance of IO, or IO-like, object. * - * For example: + * Following two example generate the same result. * * Zlib::GzipWriter.open('hoge.gz') do |gz| * gz.write 'jugemu jugemu gokou no surikire...' @@ -2864,9 +2864,15 @@ * gz.close * end * - * # TODO: test these. Are they equivalent? Can GzipWriter.new take a - * # block? + * To make like gzip(1) does, run following: * + * orig = 'hoge.txt' + * Zlib::GzipWriter.open('hoge.gz') do |gz| + * gz.mtime = File.mtime(orig) + * gz.orig_name = orig + * gz.write IO.binread(orig) + * end + * * NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close * GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter * will be not able to write the gzip footer and will generate a broken gzip -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/