@@ -8,7 +8,6 @@ add_format(format"GZIP", [0x1f, 0x8b], ".gz", [:Libz])
8
8
9
9
# test for RD?2 magic sequence at the beginning of R data input stream
10
10
function detect_rdata (io)
11
- seekstart (io)
12
11
read (io, UInt8) == UInt8 (' R' ) &&
13
12
read (io, UInt8) == UInt8 (' D' ) &&
14
13
read (io, UInt8) in (UInt8 (' A' ), UInt8 (' B' ), UInt8 (' X' )) &&
19
18
add_format (format " RData" , detect_rdata, [" .rda" , " .RData" , " .rdata" ], [:RData , LOAD])
20
19
21
20
function detect_rdata_single (io)
22
- seekstart (io)
23
21
res = read (io, UInt8) in (UInt8 (' A' ), UInt8 (' B' ), UInt8 (' X' )) &&
24
22
(c = read (io, UInt8); c == UInt8 (' \n ' ) || (c == UInt8 (' \r ' ) && read (io, UInt8) == UInt8 (' \n ' )))
25
- seekstart (io)
26
23
return res
27
24
end
28
25
@@ -145,10 +142,9 @@ add_format(format"GSLIB", (), [".gslib",".sgems"], [:GslibIO])
145
142
146
143
# ## Audio formats
147
144
function detectwav (io)
148
- seekstart (io)
149
145
magic = read! (io, Vector {UInt8} (4 ))
150
146
magic == b " RIFF" || return false
151
- seek (io, 8 )
147
+ skip (io, 4 )
152
148
submagic = read! (io, Vector {UInt8} (4 ))
153
149
154
150
submagic == b " WAVE"
@@ -200,10 +196,9 @@ skipmagic(io, ::typeof(detect_noometiff)) = seek(io, 4)
200
196
201
197
# AVI is a subtype of RIFF, as is WAV
202
198
function detectavi (io)
203
- seekstart (io)
204
199
magic = read! (io, Vector {UInt8} (4 ))
205
200
magic == b " RIFF" || return false
206
- seek (io, 8 )
201
+ skip (io, 4 )
207
202
submagic = read! (io, Vector {UInt8} (4 ))
208
203
209
204
submagic == b " AVI "
@@ -212,6 +207,8 @@ add_format(format"AVI", detectavi, ".avi", [:ImageMagick])
212
207
213
208
# HDF5: the complication is that the magic bytes may start at
214
209
# 0, 512, 1024, 2048, or any multiple of 2 thereafter
210
+ # this detection function assumes that the stream start and end match the
211
+ # file start and end, which is true if it's just a file on disk
215
212
h5magic = (0x89 ,0x48 ,0x44 ,0x46 ,0x0d ,0x0a ,0x1a ,0x0a )
216
213
function detecthdf5 (io)
217
214
position (io) == 0 || return false
@@ -234,6 +231,8 @@ function detecthdf5(io)
234
231
end
235
232
add_format (format " HDF5" , detecthdf5, [" .h5" , " .hdf5" ], [:HDF5 ])
236
233
234
+ # the STL detection functions assumes that the stream start and end match the
235
+ # file start and end, which is true if it's just a file on disk
237
236
function detect_stlascii (io)
238
237
try
239
238
position (io) != 0 && (seekstart (io); return false )
0 commit comments