Class: UnpackStrategy::Tar

Inherits:
Object
  • Object
show all
Includes:
UnpackStrategy
Defined in:
brew/Library/Homebrew/unpack_strategy/tar.rb

Direct Known Subclasses

Compress

Instance Attribute Summary

Attributes included from UnpackStrategy

#merge_xattrs, #path

Class Method Summary collapse

Methods included from UnpackStrategy

#dependencies, detect, #extract, #extract_nestedly, from_extension, from_magic, from_type, #initialize

Class Method Details

.can_extract?(path) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
# File 'brew/Library/Homebrew/unpack_strategy/tar.rb', line 19

def self.can_extract?(path)
  return true if path.magic_number.match?(/\A.{257}ustar/n)

  return false unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) }

  # Check if `tar` can list the contents, then it can also extract it.
  IO.popen(["tar", "tf", path], err: File::NULL) do |stdout|
    !stdout.read(1).nil?
  end
end

.extensionsObject



9
10
11
12
13
14
15
16
17
# File 'brew/Library/Homebrew/unpack_strategy/tar.rb', line 9

def self.extensions
  [
    ".tar",
    ".tbz", ".tbz2", ".tar.bz2",
    ".tgz", ".tar.gz",
    ".tlzma", ".tar.lzma",
    ".txz", ".tar.xz"
  ]
end