aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/container/cab.rb
blob: 010fccbc40fd0d06d65340f121aa09127ff2aa85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "tmpdir"

require "hbc/container/base"

module Hbc
  class Container
    class Cab < Base
      def self.me?(criteria)
        criteria.magic_number(/^(MSCF|MZ)/n)
      end

      def extract
        if (cabextract = which("cabextract")).nil?
          raise CaskError, "Expected to find cabextract executable. Cask '#{@cask}' must add: depends_on formula: 'cabextract'"
        end

        Dir.mktmpdir do |unpack_dir|
          @command.run!(cabextract, args: ["-d", unpack_dir, "--", @path])
          @command.run!("/usr/bin/ditto", args: ["--", unpack_dir, @cask.staged_path])
        end
      end
    end
  end
end