Class: MooTool::Controllers::KernelCollection
- Inherits:
-
MooTool::ControllerBase
- Object
- MooTool::ControllerBase
- MooTool::Controllers::KernelCollection
- Defined in:
- lib/mootool/controllers/kernel_collection.rb
Overview
Controller for extracting or viewing a KernelCollection (.kc file)
Instance Method Summary collapse
Methods inherited from MooTool::ControllerBase
command, description, for_controller, inherited, load_all
Instance Method Details
#extract(command, output_folder) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mootool/controllers/kernel_collection.rb', line 11 def extract(command, output_folder) file = command.file input = File.open(command.file, 'rb') T.must(file).command(:LC_FILESET_ENTRY).each do |entry| output_path = File.join(output_folder, entry.entry_id.to_s) puts "Writing to #{output_path}" output_file = File.open(output_path, 'wb') # rubocop:disable Naming/VariableNumber # We do not have control of this name as it is part of ruby-macho matching = T.must(file).command(:LC_SEGMENT_64).find { |c| c.fileoff == entry.fileoff } # rubocop:enable Naming/VariableNumber input.seek(matching.fileoff) output_file.write input.read(matching.filesize) output_file.close end end |