November 2008
Intermediate to advanced
208 pages
4h 32m
English
This script shows you the basics of decompressing a file. The rubyzip library does all of the work for you. On a standard Unix-like system, you would have to manually unzip the file, carry out your task, and then re-compress the file. With rubyzip, you can work with files in an archive using one seamless library. This script completely decompresses an archive into the user-specified directory.
require 'zip/zip'
require 'fileutils'
unless ARGV[0]
puts "Usage: ruby decompress.rb <zipfilename.zip>"
puts "Example: ruby decompress.rb myfile.zip"
exit
end
archive = ARGV[0].chomp
if File.exists?(archive) ...Read now
Unlock full access