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
|
# File 'lib/minizip/zip.rb', line 28
def self.(zip_name, options)
if options && options.is_a?(String)
puts "[DEPRECATED] Passing in 'directory' as the second argument is deprecated. Please pass it in as part of a hash instead, like this: extract(#{zip_name}, :directory => #{options}) #{caller.first}"
options = {:directory => options}
end
options = options.with_indifferent_access
directory = options[:directory]
if File.exists?(zip_name)
Dir.mkdir(directory) if directory && !File.exists?(directory)
if USING_WINDOWS
overwrite = options['overwrite'] ? '-y' : nil
if directory
system "7za x #{zip_name} -o#{directory} #{overwrite}"
else
system "7za x #{zip_name} #{overwrite}"
end
else
overwrite = options['overwrite'] ? '-o' : nil
if directory
system "unzip #{overwrite} '#{zip_name}' -d #{directory}"
else
system "unzip #{overwrite} '#{zip_name}'"
end
end
else
puts "#{zip_name} doesn't exist in #{Dir.pwd}"
end
end
|