Merge pull request #2410 from reitermarkus/container-exectuable
Add `Container::Executable`.
This commit is contained in:
commit
0882e9ddbc
@ -4,6 +4,7 @@ require "hbc/container/bzip2"
|
||||
require "hbc/container/cab"
|
||||
require "hbc/container/criteria"
|
||||
require "hbc/container/dmg"
|
||||
require "hbc/container/executable"
|
||||
require "hbc/container/generic_unar"
|
||||
require "hbc/container/gzip"
|
||||
require "hbc/container/lzma"
|
||||
@ -39,6 +40,7 @@ module Hbc
|
||||
Gzip, # pure gzip
|
||||
Lzma, # pure lzma
|
||||
Xz, # pure xz
|
||||
Executable,
|
||||
]
|
||||
# for explicit use only (never autodetected):
|
||||
# Hbc::Container::Naked
|
||||
|
||||
18
Library/Homebrew/cask/lib/hbc/container/executable.rb
Normal file
18
Library/Homebrew/cask/lib/hbc/container/executable.rb
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user