2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/jpeg_reader.rb', line 2
def self.fetch_data_from(filename)
data = ""
File.open(filename, "r") do |f|
if f.read(2) == "\xff\xd8".to_b
while !f.eof?
break if f.read(1) != "\xff".to_b
if f.read(1) == "\xe0".to_b quickroute_segment = false
length = BinData::Uint16be.read(f)
if length >= 12
if f.read(10) == "QuickRoute".to_b
data << f.read(length - 12)
quickroute_segment = true
else
f.seek(length - 12, ::IO::SEEK_CUR)
end
else
f.seek(length - 2, ::IO::SEEK_CUR)
end
break if !quickroute_segment && !data.empty?
else
break
end
end
end
end
data
end
|