Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stream = File.open(ARGV.shift)
- blksize = stream.stat.blksize
- bytes_required = 32
- start = stream.read(bytes_required)
- match = String.new
- buffer = String.new
- while stream.read(blksize, buffer)
- buffer.bytes.with_index do |byte, index|
- match.concat(byte)
- start.start_with?(match) or next match.clear
- match.eql?(start) and break begin
- puts("Sequence restarted at:")
- puts(stream.pos-blksize+index-bytes_required)
- abort(match)
- end
- end or break
- end
- puts("Found nothing.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement