Skip to content

Commit

Permalink
Merge pull request #116 from trofi/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco authored Oct 6, 2021
2 parents 222f41a + ef95531 commit 8256dba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libarchive/ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
c_ssize_t, c_void_p, c_void_p, POINTER(c_void_p)
)
SEEK_CALLBACK = CFUNCTYPE(
c_longlong, c_int, c_void_p, c_longlong, c_int
c_longlong, c_void_p, c_void_p, c_longlong, c_int
)
OPEN_CALLBACK = CFUNCTYPE(c_int, c_void_p, c_void_p)
CLOSE_CALLBACK = CFUNCTYPE(c_int, c_void_p, c_void_p)
Expand Down
6 changes: 4 additions & 2 deletions libarchive/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ def custom_reader(
open_cb = OPEN_CALLBACK(open_func) if open_func else NO_OPEN_CB
read_cb = READ_CALLBACK(read_func)
close_cb = CLOSE_CALLBACK(close_func) if close_func else NO_CLOSE_CB
seek_cb = SEEK_CALLBACK(seek_func)
with new_archive_read(format_name, filter_name, passphrase) as archive_p:
if seek_func:
ffi.read_set_seek_callback(archive_p, SEEK_CALLBACK(seek_func))
ffi.read_set_seek_callback(archive_p, seek_cb)
ffi.read_open(archive_p, None, open_cb, read_cb, close_cb)
yield archive_read_class(archive_p)

Expand Down Expand Up @@ -143,9 +144,10 @@ def seek_func(archive_p, context, offset, whence):
open_cb = NO_OPEN_CB
read_cb = READ_CALLBACK(read_func)
close_cb = NO_CLOSE_CB
seek_cb = SEEK_CALLBACK(seek_func)
with new_archive_read(format_name, filter_name, passphrase) as archive_p:
if stream.seekable():
ffi.read_set_seek_callback(archive_p, SEEK_CALLBACK(seek_func))
ffi.read_set_seek_callback(archive_p, seek_cb)
ffi.read_open(archive_p, None, open_cb, read_cb, close_cb)
yield ArchiveRead(archive_p)

Expand Down

0 comments on commit 8256dba

Please sign in to comment.