Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ os:
julia:
- 0.6
- nightly
matrix:
allow_failures:
- julia: nightly
notifications:
email: false
# uncomment the following lines to override the default test script
Expand Down
9 changes: 9 additions & 0 deletions src/compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ function TranscodingStreams.finalize(codec::ZstdCompression)
return
end

function TranscodingStreams.startproc(codec::ZstdCompression, mode::Symbol, error::Error)
code = reset!(codec.cstream, 0 #=unknown source size=#)
if iserror(code)
error[] = ErrorException("zstd error")
return :error
end
return :ok
end

function TranscodingStreams.process(codec::ZstdCompression, input::Memory, output::Memory, error::Error)
cstream = codec.cstream
cstream.ibuffer.src = input.ptr
Expand Down
9 changes: 9 additions & 0 deletions src/decompression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ function TranscodingStreams.finalize(codec::ZstdDecompression)
return
end

function TranscodingStreams.startproc(codec::ZstdDecompression, mode::Symbol, error::Error)
code = reset!(codec.dstream)
if iserror(code)
error[] = ErrorException("zstd error")
return :error
end
return :ok
end

function TranscodingStreams.process(codec::ZstdDecompression, input::Memory, output::Memory, error::Error)
dstream = codec.dstream
dstream.ibuffer.src = input.ptr
Expand Down
8 changes: 8 additions & 0 deletions src/libzstd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function initialize!(cstream::CStream, level::Integer)
return ccall((:ZSTD_initCStream, libzstd), Csize_t, (Ptr{Void}, Cint), cstream.ptr, level)
end

function reset!(cstream::CStream, srcsize::Integer)
return ccall((:ZSTD_resetCStream, libzstd), Csize_t, (Ptr{Void}, Culonglong), cstream.ptr, srcsize)
end

function compress!(cstream::CStream)
return ccall((:ZSTD_compressStream, libzstd), Csize_t, (Ptr{Void}, Ptr{Void}, Ptr{Void}), cstream.ptr, pointer_from_objref(cstream.obuffer), pointer_from_objref(cstream.ibuffer))
end
Expand Down Expand Up @@ -91,6 +95,10 @@ function initialize!(dstream::DStream)
return ccall((:ZSTD_initDStream, libzstd), Csize_t, (Ptr{Void},), dstream.ptr)
end

function reset!(dstream::DStream)
return ccall((:ZSTD_resetDStream, libzstd), Csize_t, (Ptr{Void},), dstream.ptr)
end

function decompress!(dstream::DStream)
return ccall((:ZSTD_decompressStream, libzstd), Csize_t, (Ptr{Void}, Ptr{Void}, Ptr{Void}), dstream.ptr, pointer_from_objref(dstream.obuffer), pointer_from_objref(dstream.ibuffer))
end
Expand Down