This module provides TAR archive functionality for the Qore programming language.
- Create and extract TAR archives
- Support for multiple compression methods: gzip, bzip2, xz, zstd, lz4
- Support for multiple TAR formats: ustar, pax, GNU, V7
- In-memory archive operations
- Streaming API for large files
- Stream-based I/O (read/write from Qore streams)
- File metadata preservation (permissions, ownership, timestamps)
- Support for special file types (symlinks, hardlinks, sparse files)
- Archive encryption and multi-volume support
- Qore 2.0 or later
- libarchive 3.0 or later
- OpenSSL (optional, for encryption support)
mkdir build && cd build
cmake ..
make
sudo make install#!/usr/bin/env qore
%requires tar
# Create a gzip-compressed archive
TarFile tar("backup.tar.gz", "w");
tar.add("file.txt", "Hello, World!");
tar.addFile("docs/readme.txt", "/path/to/readme.txt");
tar.addDirectory("empty_dir/");
tar.close();
#!/usr/bin/env qore
%requires tar
# Open and read archive
TarFile tar("backup.tar.gz", "r");
# List entries
for (hash<TarEntryInfo> entry : tar.entries()) {
printf("%s: %d bytes\n", entry.name, entry.size);
}
# Extract a specific file
binary data = tar.read("file.txt");
tar.close();
#!/usr/bin/env qore
%requires tar
TarFile tar("backup.tar.gz", "r");
tar.extractAll({"destination": "/tmp/extracted"});
tar.close();
#!/usr/bin/env qore
%requires tar
# Create archive in memory
TarFile tar();
tar.add("data.txt", "Some data");
binary archive_data = tar.toData();
# Read from memory
TarFile tar2(archive_data);
string content = tar2.readText("data.txt");
The module includes TarDataProvider for use with Qore's data provider framework:
%requires TarDataProvider
# Get the data provider factory and navigate to the action
AbstractDataProvider dp = DataProvider::getFactoryObjectFromStringEx("tar{}/archive/create");
# Execute the action
hash<auto> result = dp.doRequest({
"archive_path": "/tmp/backup.tar.gz",
"compression": "gzip",
"files": (
{"name": "file.txt", "text": "Hello, World!"},
),
});
MIT License - see COPYING.MIT for details.
Copyright 2026 Qore Technologies, s.r.o.