Skip to content

Commit

Permalink
switch to CodecZlib from Gzip (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Nov 4, 2017
1 parent 36cbd5c commit d5abbd2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Updated to Julia v0.6 (older versions not supported).
##### Changes
* R logical vectors are converted to `DataVector{Bool}` (instead of `DataVector{Int32}`) [#32]
* dropped compatibility with Julia versions prior v0.6 [#32]
* use CodecZlib for gzipped RData files (instead of outdated GZip) [#31]

[#31]: https://github.com/JuliaStats/RData.jl/issues/31
[#32]: https://github.com/JuliaStats/RData.jl/issues/32

## RData v0.0.4 Release Notes
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ julia 0.6
DataFrames 0.9
DataArrays 0.4
FileIO 0.1.2
GZip 0.2
CodecZlib 0.4
15 changes: 12 additions & 3 deletions src/RData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ __precompile__()

module RData

using DataFrames, DataArrays, GZip, FileIO
using DataFrames, DataArrays, CodecZlib, FileIO
import DataFrames: identifier
import FileIO: load

Expand Down Expand Up @@ -41,8 +41,17 @@ include("readers.jl")
##############################################################################

function load(f::File{format"RData"}; kwoptions...)
gzopen(filename(f)) do s
load(Stream(f, s), kwoptions)
io = open(filename(f), "r")
try
gzipped = read(io, UInt8) == 0x1F && read(io, UInt8) == 0x8B # check GZip magic number
seekstart(io)
# if compressed, transcode gzipped stream
gzipped && (io = GzipDecompressorStream(io))
return load(Stream(f, io), kwoptions)
catch
rethrow()
finally
close(io)
end
end

Expand Down

0 comments on commit d5abbd2

Please sign in to comment.