An easy to use multiplatform archive extraction wrapper library for 7-Zip
Project description
TitanArchive
An easy to use multiplatform archive extraction wrapper library for 7-Zip
Features
- Easy API for C and Python. Greatly simplifies the complexity of using 7-Zip
- Multiplatform. Supports Linux and Windows
- Very fast. Written in modern C++
- Automatically discovers and determines archive type
- Supports most archive formats: 7z, XZ, BZIP2, GZIP, TAR, ZIP, WIM, AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR and Z
Usage
Python
Open archive on disk:
import titanarchive
with titanarchive.TitanArchive('test.zip') as ta:
# Do actions
Open archive from memory buffer:
import titanarchive
data = open('test.zip', 'rb').read()
with titanarchive.TitanArchive(data) as ta:
# Do actions
Open archive from file descriptor:
import os
import titanarchive
fd = os.open('test.zip', os.O_RDONLY | (os.O_BINARY if os.name == 'nt' else 0))
with titanarchive.TitanArchive(fd) as ta:
# Do actions
Discover archive format:
import titanarchive
with titanarchive.TitanArchive('unknown.dat') as ta:
print('Format: {}'.format(ta.GetArchiveFormat()))
Format: zip
Print all files and directories in archive (Method 1, by path):
import titanarchive
import os
def print_files(ta, path):
for item in ta.ListDirectory(path):
full_path = os.path.join(path, item.Path)
if item.IsDir:
print_files(ta, full_path)
print('Item: {}'.format(full_path))
with titanarchive.TitanArchive('test.zip') as ta:
print_files(ta, '')
Item: dir1\another_file.txt
Item: dir1\dir2\another_file.txt
Item: dir1\dir2\dir3\file.txt
Item: dir1\dir2\dir3
Item: dir1\dir2\empty_directory
Item: dir1\dir2\file.txt
Item: dir1\dir2
Item: dir1\empty_directory
Item: dir1
Item: empty_directory
Item: file_at_root.txt
Print all files and directories in archive (Method 2, by index):
import titanarchive
with titanarchive.TitanArchive('test.zip') as ta:
try:
index = 0
while True:
item = ta.GetArchiveItemPropertiesByIndex(index)
print('Item: {}'.format(item.Path))
index += 1
except titanarchive.TitanArchiveException:
pass
Item: dir1
Item: dir1\another_file.txt
Item: dir1\dir2
Item: dir1\dir2\another_file.txt
Item: dir1\dir2\dir3
Item: dir1\dir2\dir3\file.txt
Item: dir1\dir2\empty_directory
Item: dir1\dir2\file.txt
Item: dir1\empty_directory
Item: empty_directory
Item: file_at_root.txt
Extract file to memory (Method 1, by path):
import titanarchive
with titanarchive.TitanArchive('test.zip') as ta:
data = ta.ExtractArchiveItemToBufferByPath('dir1\\another_file.txt')
print(data.read())
b'Test Data 123'
Extract file to memory (Method 2, by index):
import titanarchive
with titanarchive.TitanArchive('test.zip') as ta:
properties = ta.GetArchiveItemPropertiesByPath('dir1\\another_file.txt')
data = ta.ExtractArchiveItemToBufferByIndex(properties.Index)
print(data.read())
b'Test Data 123'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
titanarchive-2.0.tar.gz
(1.3 MB
view details)
File details
Details for the file titanarchive-2.0.tar.gz.
File metadata
- Download URL: titanarchive-2.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37658e809d38cd5977db82698d94043f7036fc451e0cda708eda1b8062dd8d8e
|
|
| MD5 |
ea868aa68370db4a2cf3e0b49fb2e45b
|
|
| BLAKE2b-256 |
521ef75b967c7396d378aca01d1f243a21b00ca588819ca01c41b36f2bc62366
|