10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/appifier/helpers/archives.rb', line 10
def untar_gz(archive:, destination:)
source = open archive
::Gem::Package::TarReader.new(Zlib::GzipReader.new(source)) do |tar|
dest = nil
tar.each do |entry|
if entry.full_name == '././@LongLink'
dest = File.join destination, entry.read.strip
next
end
dest ||= File.join destination, entry.full_name
if entry.directory?
File.delete dest if File.file? dest
FileUtils.mkdir_p dest, mode: entry..mode, verbose: false
elsif entry.file?
FileUtils.rm_rf dest if File.directory? dest
File.open dest, 'wb' do |f|
f.print entry.read
end
FileUtils.chmod entry..mode, dest, verbose: false
elsif entry..typeflag == '2' File.symlink entry..linkname, dest
end
dest = nil
end
end
end
|