libarchive is a cross-platform multi-format archive and compression library. RB-libarchive is a libarchive binding for Realbasic and Xojo ("classic" framework) projects. Library binaries for various platforms are available, or can be built from source.
The minimum supported libarchive version is 3.3.3. The minimum supported Xojo version is RS2010R4.
This example extracts an archive into a folder. More examples.
Dim src As FolderItem = GetOpenFolderItem("")
Dim dst As FolderItem = SelectFolder()
Dim lst() As libarchive.ArchiveEntry = libarchive.ReadArchive(src, dst)
- Create and extract any archive format supported by libarchive1.
- Read and write encrypted archives2.
- Read and write any compression format supported by libarchive1.
- 64-bit ready.
1 Some formats are read-only; a few are write-only.
2 Zip archives only.
If you use this code in a commercial project, or just want to show your appreciation, please consider sponsoring me through GitHub. https://github.com/sponsors/charonn0
The libarchive API is abstracted over by several object classes:
Object Class | Comment |
---|---|
ArchiveReader |
An archive opened for extraction. |
ArchiveWriter |
An archive opened for archiving. |
ArchiveEntry |
The metadata of a single entry in an archive. |
CompressedStream |
A BinaryStream workalike for reading and writing compressed streams. |
An archive is represented by an instance of ArchiveReader
or ArchiveWriter
, or a format-specific subclass of these classes. For most purposes you can use the OpenArchive, OpenAsArchive, and ReadArchive convenience methods to extract an existing archive; and the CreateArchive, CreateAsArchive, and WriteArchive convenience methods to generate a new archive.
- Download the RB-libarchive project either in ZIP archive format or by cloning the repository with your Git client.
- Open the RB-libarchive project in REALstudio or Xojo. Open your project in a separate window.
- Copy the libarchive module into your project and save.
libarchive might be not installed by default on some operating systems, in which case you will need to either install the libarchive package from the OS vendor or ship the necessary files with your application.
- Windows: 32-bit and 64-bit DLLs
- macOS: 32-bit and 64-bit dylibs (untested; might not be needed. Be sure to update the
libarchive.libpath
constant to point to this file.) - Linux: Install the
libarchive-13
(or equivalent) package through the system package manager if it is not already installed.
RB-libarchive will raise a PlatformNotSupportedException when used if all required DLLs/SOs/DyLibs are not available at runtime.