From 1be120f4c1d7f0be24ead200a6cb0925acc90129 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 28 Mar 2017 15:34:34 +0200 Subject: Add `Container::Executable`. --- Library/Homebrew/cask/lib/hbc/container/executable.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Library/Homebrew/cask/lib/hbc/container/executable.rb (limited to 'Library/Homebrew/cask/lib/hbc/container/executable.rb') diff --git a/Library/Homebrew/cask/lib/hbc/container/executable.rb b/Library/Homebrew/cask/lib/hbc/container/executable.rb new file mode 100644 index 000000000..848f6d4be --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/container/executable.rb @@ -0,0 +1,18 @@ +require "hbc/container/naked" +require "vendor/macho/macho" + +module Hbc + class Container + class Executable < Naked + def self.me?(criteria) + return true if criteria.magic_number(/^#!\s*\S+/) + + begin + MachO.open(criteria.path).header.executable? + rescue MachO::MagicError + false + end + end + end + end +end -- cgit v1.2.3