class SmcUtil::FileExtractor
Constants
- OUTPUT_FILE_FLAGS
Public Class Methods
new(file_reader)
click to toggle source
# File lib/smcutil/file_extractor.rb, line 4 def initialize(file_reader) @file_reader = file_reader end
Public Instance Methods
extract_to(path)
click to toggle source
# File lib/smcutil/file_extractor.rb, line 9 def extract_to(path) File.open(path, OUTPUT_FILE_FLAGS) do |file| @file_reader.regions.each do |region| range_bytes = region.offset - file.pos file.write "\0" * range_bytes if range_bytes > 0 file.seek region.offset file.write region.data end end end
shred_to(path)
click to toggle source
# File lib/smcutil/file_extractor.rb, line 20 def shred_to(path) Dir.mkdir(path) unless Dir.exists? path pass = position = 0 @file_reader.regions.each do |region| pass += 1 if region.offset < position position = region.offset filename = File.join(path, "pass#{pass}_#{region.offset.to_s(16)}.bin") File.open(filename, OUTPUT_FILE_FLAGS) do |file| file.write region.data end end end