Ruby/Development/zip
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:55, 13 сентября 2010
Append to a zip file
require "zlib" file = "compressed.gz" Zlib::GzipWriter.open(file) do |gzip| gzip << "this is a test." gzip.close end open("compressed.gz", "wb") do |file| gzip = Zlib::GzipWriter.new(file) gzip << "this is a test." gzip.close end
Compressing and Archiving Files with Gzip and Tar
require "zlib" file = "compressed.gz" Zlib::GzipWriter.open(file) do |gzip| gzip << "this is a test." gzip.close end open(file, "rb") { |f| f.read(10) } Zlib::GzipReader.open(file) { |gzip| puts gzip.read }
Inflate and deflate a string
require "zlib" deflated = Zlib::Deflate.deflate("this is a test.") puts deflated puts Zlib::Inflate.inflate(deflated)