@@ -8,7 +8,6 @@ add_format(format"GZIP", [0x1f, 0x8b], ".gz", [:Libz])
8
8
9
9
# test for RD?n 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} (undef, 4 ))
150
146
magic == b " RIFF" || return false
151
- seek (io, 8 )
147
+ skip (io, 4 )
152
148
submagic = read! (io, Vector {UInt8} (undef, 4 ))
153
149
154
150
submagic == b " WAVE"
@@ -198,10 +194,9 @@ skipmagic(io, ::typeof(detect_noometiff)) = seek(io, 4)
198
194
199
195
# AVI is a subtype of RIFF, as is WAV
200
196
function detectavi (io)
201
- seekstart (io)
202
197
magic = read! (io, Vector {UInt8} (undef, 4 ))
203
198
magic == b " RIFF" || return false
204
- seek (io, 8 )
199
+ skip (io, 4 )
205
200
submagic = read! (io, Vector {UInt8} (undef, 4 ))
206
201
207
202
submagic == b " AVI "
@@ -210,6 +205,8 @@ add_format(format"AVI", detectavi, ".avi", [:ImageMagick])
210
205
211
206
# HDF5: the complication is that the magic bytes may start at
212
207
# 0, 512, 1024, 2048, or any multiple of 2 thereafter
208
+ # this detection function assumes that the stream start and end match the
209
+ # file start and end, which is true if it's just a file on disk
213
210
h5magic = (0x89 ,0x48 ,0x44 ,0x46 ,0x0d ,0x0a ,0x1a ,0x0a )
214
211
function detecthdf5 (io)
215
212
position (io) == 0 || return false
@@ -232,6 +229,8 @@ function detecthdf5(io)
232
229
end
233
230
add_format (format " HDF5" , detecthdf5, [" .h5" , " .hdf5" ], [:HDF5 ])
234
231
232
+ # the STL detection functions assumes that the stream start and end match the
233
+ # file start and end, which is true if it's just a file on disk
235
234
function detect_stlascii (io)
236
235
pos = position (io)
237
236
try
@@ -283,4 +282,4 @@ add_format(format"MetaImage", "ObjectType", ".mhd", [:MetaImageFormat])
283
282
284
283
add_format (format " vegalite" , (), [" .vegalite" ], [:VegaLite ])
285
284
286
- add_format (format " FCS" , " FCS" , [" .fcs" ], [:FCSFiles ])
285
+ add_format (format " FCS" , " FCS" , [" .fcs" ], [:FCSFiles ])
0 commit comments