@@ -39,7 +39,7 @@ An easy way to write `DataFormat{:CSV}` is `format"CSV"`.
39
39
immutable DataFormat{sym} end
40
40
41
41
macro format_str (s)
42
- :(DataFormat{$ (Expr (:quote , symbol (s)))})
42
+ :(DataFormat{$ (Expr (:quote , @compat Symbol (s)))})
43
43
end
44
44
45
45
const unknown_df = DataFormat{:UNKNOWN }
@@ -49,7 +49,7 @@ const unknown_df = DataFormat{:UNKNOWN}
49
49
unknown (:: Type{format"UNKNOWN"} ) = true
50
50
unknown {sym} (:: Type{DataFormat{sym}} ) = false
51
51
52
- const ext2sym = Dict {ASCIIString , @compat(Union{Symbol,Vector{Symbol}})} ()
52
+ const ext2sym = Dict {String , @compat(Union{Symbol,Vector{Symbol}})} ()
53
53
const magic_list = Array (Pair, 0 ) # sorted, see magic_cmp below
54
54
const sym2info = Dict {Symbol,Any} () # Symbol=>(magic, extension)
55
55
const magic_func = Array (Pair, 0 ) # for formats with complex magic #s
@@ -73,7 +73,7 @@ For example:
73
73
74
74
Note that extensions, magic numbers, and format-identifiers are case-sensitive.
75
75
""" ->
76
- function add_format {sym} (fmt:: Type{DataFormat{sym}} , magic: :@compat (Union{Tuple,AbstractVector,ByteString }), extension)
76
+ function add_format {sym} (fmt:: Type{DataFormat{sym}} , magic: :@compat (Union{Tuple,AbstractVector,String }), extension)
77
77
haskey (sym2info, sym) && error (" format " , fmt, " is already registered" )
78
78
m = canonicalize_magic (magic)
79
79
rng = searchsorted (magic_list, m, lt= magic_cmp)
@@ -155,11 +155,11 @@ Base.info{sym}(::Type{DataFormat{sym}}) = sym2info[sym]
155
155
156
156
canonicalize_magic {N} (m:: NTuple{N,UInt8} ) = m
157
157
canonicalize_magic (m:: AbstractVector{UInt8} ) = tuple (m... )
158
- canonicalize_magic (m:: ByteString ) = canonicalize_magic (m. data)
158
+ canonicalize_magic (m:: String ) = canonicalize_magic (m. data)
159
159
160
160
161
161
162
- function add_extension (ext:: ASCIIString , sym)
162
+ function add_extension (ext:: String , sym)
163
163
if haskey (ext2sym, ext)
164
164
v = ext2sym[ext]
165
165
if isa (v, Symbol)
@@ -177,7 +177,7 @@ function add_extension(ext::@compat(Union{Array,Tuple}), sym)
177
177
end
178
178
end
179
179
180
- del_extension (ext:: ASCIIString ) = delete! (ext2sym, ext)
180
+ del_extension (ext:: String ) = delete! (ext2sym, ext)
181
181
function del_extension (ext: :@compat (Union{Array,Tuple}))
182
182
for e in ext
183
183
del_extension (e)
@@ -213,7 +213,7 @@ abstract Formatted{F<:DataFormat} # A specific file or stream
213
213
DataFormat `fmt`. For example, `File{fmtpng}(filename)` would indicate a PNG
214
214
file.""" ->
215
215
immutable File{F<: DataFormat } <: Formatted{F}
216
- filename:: UTF8String
216
+ filename:: Compat. UTF8String
217
217
end
218
218
File {sym} (fmt:: Type{DataFormat{sym}} , filename) = File {fmt} (filename)
219
219
@@ -236,10 +236,10 @@ indicate PNG format. If known, the optional `filename` argument can
236
236
be used to improve error messages, etc.""" ->
237
237
immutable Stream{F<: DataFormat ,IOtype<: IO } <: Formatted{F}
238
238
io:: IOtype
239
- filename:: Nullable{UTF8String}
239
+ filename:: Nullable{Compat. UTF8String}
240
240
end
241
241
242
- Stream {F<:DataFormat} (:: Type{F} , io:: IO ) = Stream {F,typeof(io)} (io, Nullable {UTF8String} ())
242
+ Stream {F<:DataFormat} (:: Type{F} , io:: IO ) = Stream {F,typeof(io)} (io, Nullable {Compat. UTF8String} ())
243
243
Stream {F<:DataFormat} (:: Type{F} , io:: IO , filename:: AbstractString ) = Stream {F,typeof(io)} (io,utf8 (filename))
244
244
Stream {F<:DataFormat} (:: Type{F} , io:: IO , filename) = Stream {F,typeof(io)} (io,filename)
245
245
Stream {F} (file:: File{F} , io:: IO ) = Stream {F,typeof(io)} (io,filename (file))
@@ -287,12 +287,15 @@ Base.eof(s::Stream) = eof(stream(s))
287
287
Base. read! (s:: Stream , array:: Array ) = read! (stream (s), array)
288
288
@inline Base. write (s:: Stream , args... ) = write (stream (s), args... )
289
289
# Note: we can't sensibly support the all keyword. If you need that,
290
- # call readbytes (stream(s), ...; all=value) manually
290
+ # call read (stream(s), ...; all=value) manually
291
291
Base. readbytes! (s:: Stream , b) = readbytes! (stream (s), b)
292
292
Base. readbytes! (s:: Stream , b, nb) = readbytes! (stream (s), b, nb)
293
- Base. readbytes (s:: Stream ) = readbytes (stream (s))
294
- Base. readbytes (s:: Stream , nb) = readbytes (stream (s), nb)
293
+ Base. read (s:: Stream ) = read (stream (s))
294
+ Base. read (s:: Stream , nb) = read (stream (s), nb)
295
295
Base. flush (s:: Stream ) = flush (stream (s))
296
+ # 0.4 compat
297
+ Base. readbytes (s:: Stream ) = read (stream (s))
298
+ Base. readbytes (s:: Stream , nb) = read (stream (s), nb)
296
299
297
300
Base. isreadonly (s:: Stream ) = isreadonly (stream (s))
298
301
Base. isopen (s:: Stream ) = isopen (stream (s))
@@ -321,7 +324,7 @@ function skipmagic(io, magic::Tuple)
321
324
len = position (io)
322
325
seekstart (io)
323
326
filter! (x-> length (x) <= len, magic) # throw out magic bytes that are longer than IO
324
- tmp = readbytes (io, length (first (magic))) # now, first is both the longest and guaranteed to fit into io, so we can just read the bytes
327
+ tmp = read (io, length (first (magic))) # now, first is both the longest and guaranteed to fit into io, so we can just read the bytes
325
328
for m in magic
326
329
if magic_equal (m, tmp)
327
330
seek (io, length (m))
@@ -382,7 +385,7 @@ hasfunction(s::Tuple) = false #has magic
382
385
format inferred from the magic bytes.""" ->
383
386
query (io:: IO , filename) = query (io, Nullable (utf8 (filename)))
384
387
385
- function query (io:: IO , filename:: Nullable{UTF8String} = Nullable {UTF8String} ())
388
+ function query (io:: IO , filename:: Nullable{Compat. UTF8String} = Nullable {Compat. UTF8String} ())
386
389
magic = Array (UInt8, 0 )
387
390
pos = position (io)
388
391
for p in magic_list
0 commit comments