Object
This is the base module for the bzip2-ruby gem. Beneath it are the classes for writing and reading data from bzip2 compressed and uncompressed streams.
For example usage, see the Bzip2::Reader or Bzip2::Writer or the README
@see Bzip2::Writer @see Bzip2::Reader
This file is mostly here for documentation purposes, do not require this
Shortcut for compressing just a string.
Bzip2.uncompress Bzip2.compress('data') # => 'data'
@param [String] str the string to compress @return [String] str compressed with bz2
static VALUE bz_compress(int argc, VALUE *argv, VALUE obj) { VALUE bz2, str; if (!argc) { rb_raise(rb_eArgError, "need a String to compress"); } str = rb_str_to_str(argv[0]); argv[0] = Qnil; bz2 = rb_funcall2(bz_cWriter, id_new, argc, argv); if (OBJ_TAINTED(str)) { struct bz_file *bzf; Data_Get_Struct(bz2, struct bz_file, bzf); OBJ_TAINT(bzf->io); } bz_writer_write(bz2, str); return bz_writer_close(bz2); }
Bzip2.uncompress Bzip2.compress('asdf') # => 'asdf'
@param [String] data bz2 compressed data @return [String] data as uncompressed bz2 data @raise [Bzip2::Error] if data is not valid bz2 data
static VALUE bz_uncompress(int argc, VALUE *argv, VALUE obj) { VALUE bz2, nilv = Qnil; if (!argc) { rb_raise(rb_eArgError, "need a String to Uncompress"); } argv[0] = rb_str_to_str(argv[0]); bz2 = rb_funcall2(bz_cReader, id_new, argc, argv); return bz_reader_read(1, &nilv, bz2); }
Generated with the Darkfish Rdoc Generator 2.