2017-03-28 15:34:34 +02:00
|
|
|
require "hbc/container/naked"
|
2017-05-07 17:28:39 +01:00
|
|
|
require "vendor/macho/macho"
|
2017-03-28 15:34:34 +02:00
|
|
|
|
|
|
|
module Hbc
|
|
|
|
class Container
|
|
|
|
class Executable < Naked
|
2018-07-16 09:16:50 +02:00
|
|
|
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
|
2018-07-16 09:16:50 +02:00
|
|
|
path.file? && MachO.open(path).header.executable?
|
2017-03-28 15:34:34 +02:00
|
|
|
rescue MachO::MagicError
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|