@@ -8,7 +8,6 @@ add_format(format"GZIP", [0x1f, 0x8b], ".gz", [:Libz])
88
99# test for RD?n magic sequence at the beginning of R data input stream
1010function detect_rdata (io)
11- seekstart (io)
1211 read (io, UInt8) == UInt8 (' R' ) &&
1312 read (io, UInt8) == UInt8 (' D' ) &&
1413 read (io, UInt8) in (UInt8 (' A' ), UInt8 (' B' ), UInt8 (' X' )) &&
1918add_format (format " RData" , detect_rdata, [" .rda" , " .RData" , " .rdata" ], [:RData , LOAD])
2019
2120function detect_rdata_single (io)
22- seekstart (io)
2321 res = read (io, UInt8) in (UInt8 (' A' ), UInt8 (' B' ), UInt8 (' X' )) &&
2422 (c = read (io, UInt8); c == UInt8 (' \n ' ) || (c == UInt8 (' \r ' ) && read (io, UInt8) == UInt8 (' \n ' )))
25- seekstart (io)
2623 return res
2724end
2825
@@ -145,10 +142,9 @@ add_format(format"GSLIB", (), [".gslib",".sgems"], [:GslibIO])
145142
146143# ## Audio formats
147144function detectwav (io)
148- seekstart (io)
149145 magic = read! (io, Vector {UInt8} (undef, 4 ))
150146 magic == b " RIFF" || return false
151- seek (io, 8 )
147+ skip (io, 4 )
152148 submagic = read! (io, Vector {UInt8} (undef, 4 ))
153149
154150 submagic == b " WAVE"
@@ -198,10 +194,9 @@ skipmagic(io, ::typeof(detect_noometiff)) = seek(io, 4)
198194
199195# AVI is a subtype of RIFF, as is WAV
200196function detectavi (io)
201- seekstart (io)
202197 magic = read! (io, Vector {UInt8} (undef, 4 ))
203198 magic == b " RIFF" || return false
204- seek (io, 8 )
199+ skip (io, 4 )
205200 submagic = read! (io, Vector {UInt8} (undef, 4 ))
206201
207202 submagic == b " AVI "
@@ -210,6 +205,8 @@ add_format(format"AVI", detectavi, ".avi", [:ImageMagick])
210205
211206# HDF5: the complication is that the magic bytes may start at
212207# 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
213210h5magic = (0x89 ,0x48 ,0x44 ,0x46 ,0x0d ,0x0a ,0x1a ,0x0a )
214211function detecthdf5 (io)
215212 position (io) == 0 || return false
@@ -232,6 +229,8 @@ function detecthdf5(io)
232229end
233230add_format (format " HDF5" , detecthdf5, [" .h5" , " .hdf5" ], [:HDF5 ])
234231
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
235234function detect_stlascii (io)
236235 pos = position (io)
237236 try
@@ -283,4 +282,4 @@ add_format(format"MetaImage", "ObjectType", ".mhd", [:MetaImageFormat])
283282
284283add_format (format " vegalite" , (), [" .vegalite" ], [:VegaLite ])
285284
286- add_format (format " FCS" , " FCS" , [" .fcs" ], [:FCSFiles ])
285+ add_format (format " FCS" , " FCS" , [" .fcs" ], [:FCSFiles ])
0 commit comments