File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,31 @@ function Reader:seek(key)
113113 end
114114end
115115
116+ function Reader :extractIterator (key )
117+ self .err = nil
118+ local entry = self :seek (key )
119+ if not entry or entry .mode ~= " file" then
120+ return
121+ end
122+ -- We can't consume the data twice: tweak the index
123+ -- to trigger a reset in case of subsequent attempt.
124+ self .index = self .index + 0.1
125+ local buff = ffi .new (" const void *[1]" )
126+ local size = ffi .new (" size_t [1]" )
127+ local offs = ffi .new (" int64_t [1]" )
128+ return function ()
129+ local ok = libarchive .archive_read_data_block (self .archive , buff , size , offs )
130+ if ok == libarchive .ARCHIVE_EOF then
131+ return
132+ end
133+ if ok ~= libarchive .ARCHIVE_OK then
134+ self .err = archive_error_string (self .archive )
135+ return
136+ end
137+ return buff [0 ], size [0 ], offs [0 ]
138+ end
139+ end
140+
116141function Reader :extractToMemory (key )
117142 self .err = nil
118143 local entry = self :seek (key )
You can’t perform that action at this time.
0 commit comments