Hi,
As part of my work with pharo-cig
https://github.com/estebanlm/pharo-cig I am releasing a new pharo
library binding. This time for |libarchive|, a multi-format archive and
compression library: pharo-archive
https://github.com/estebanlm/pharo-archive.
You can read and write any zip file:
|"list contents of a file" | fileRef arc archive paths entryHolder entry
| arc := LibArchive uniqueInstance. fileRef := '/path/to/file.zip'
asFileReference. fileRef exists ifFalse: [ self error: 'File ', fileRef
fullName, ' not found.' ]. archive := arc read_new. arc
read_support_filter_all: archive. arc read_support_format_all: archive.
arc read_open_filenameArg1: archive _filename: fileRef fullName
_block_size: 10240. paths := OrderedCollection new. entryHolder :=
ArchiveEntry newValueHolder. [ (arc read_next_headerArg1: archive arg2:
entryHolder) = 0 ] whileTrue: [ entry := entryHolder value. paths add:
(arc entry_pathname: entry). arc read_data_skip: archive. ]. arc
read_free: archive. paths inspect |
Esteban
These are really nice utility things we can leverage (and a great example of the utility of pharo-cig) - thanks for doing this and sharing the work!
On Sat, 5 Jul 2025, at 11:18 AM, Esteban Lorenzano via Pharo-users wrote:
Hi,
As part of my work with pharo-cig https://github.com/estebanlm/pharo-cig I am releasing a new pharo library binding. This time for libarchive
, a multi-format archive and compression library: pharo-archive https://github.com/estebanlm/pharo-archive.
You can read and write any zip file:
`
"list contents of a file"
| fileRef arc archive paths entryHolder entry |
arc := LibArchive uniqueInstance.
fileRef := '/path/to/file.zip' asFileReference.
fileRef exists
ifFalse: [ self error: 'File ', fileRef fullName, ' not found.' ].
archive := arc read_new.
arc read_support_filter_all: archive.
arc read_support_format_all: archive.
arc
read_open_filenameArg1: archive
_filename: fileRef fullName
_block_size: 10240.
paths := OrderedCollection new.
entryHolder := ArchiveEntry newValueHolder.
[ (arc read_next_headerArg1: archive arg2: entryHolder) = 0 ]
whileTrue: [
entry := entryHolder value.
paths add: (arc entry_pathname: entry).
arc read_data_skip: archive.
].
arc read_free: archive.
paths inspect
`
Esteban