19 lines
390 B
Ruby
Raw Normal View History

2017-03-28 15:34:34 +02:00
require "hbc/container/naked"
require "vendor/macho/macho"
2017-03-28 15:34:34 +02:00
module Hbc
class Container
class Executable < Naked
def self.can_extract?(path:, magic_number:)
return true if magic_number.match?(/\A#!\s*\S+/n)
2017-03-28 15:34:34 +02:00
begin
path.file? && MachO.open(path).header.executable?
2017-03-28 15:34:34 +02:00
rescue MachO::MagicError
false
end
end
end
end
end