Skip to main content

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:

from titanarchive import TitanArchive

with TitanArchive('test.zip') as ta:
    # Do actions

Open archive from memory buffer:

from titanarchive import TitanArchive

data = open('test.zip', 'rb').read()

with TitanArchive(data) as ta:
    # Do actions

Open archive from file descriptor:

import os
from titanarchive import TitanArchive

fd = os.open('test.zip', os.O_RDONLY | (os.O_BINARY if os.name == 'nt' else 0))

with TitanArchive(fd) as ta:
    # Do actions

Show supported archive formats:

import titanarchive

print(titanarchive.GlobalGetSupportedArchiveFormats())
['APFS', 'APM', 'Ar', 'Arj', 'Base64', 'bzip2', 'Compound', 'Cpio', 'CramFS', 'Dmg', 'ELF', 'Ext', 'FAT', 'FLV', 'gzip', 'GPT', 'HFS', 'IHex', 'LP', 'Lzh', 'lzma', 'lzma86', 'MachO', 'MBR', 'MsLZ', 'Mub', 'NTFS', 'PE', 'COFF', 'TE', 'Ppmd', 'QCOW', 'Rpm', 'Sparse', 'Split', 'SquashFS', 'SWFc', 'SWF', 'UEFIc', 'UEFIf', 'VDI', 'VHD', 'VHDX', 'VMDK', 'Xar', 'xz', 'Z', '7z', 'Cab', 'Chm', 'Hxs', 'Iso', 'Nsis', 'Rar', 'Rar5', 'tar', 'Udf', 'wim', 'zip']

Discover archive format:

from titanarchive import TitanArchive

with TitanArchive('unknown.dat') as ta:
    print('Format: {}'.format(ta.GetArchiveFormat()))
Format: zip

Print all files and directories in archive (Method 1, by path):

from titanarchive 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('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):

from titanarchive import TitanArchive

with 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):

from titanarchive import TitanArchive

with 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):

from titanarchive import TitanArchive

with 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


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.1.tar.gz (1.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

titanarchive-2.1-py3-none-win_amd64.whl (867.6 kB view details)

Uploaded Python 3Windows x86-64

titanarchive-2.1-py3-none-win32.whl (784.6 kB view details)

Uploaded Python 3Windows x86

File details

Details for the file titanarchive-2.1.tar.gz.

File metadata

  • Download URL: titanarchive-2.1.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

Hashes for titanarchive-2.1.tar.gz
Algorithm Hash digest
SHA256 1f8d6284aece4063e1c8649f1aef3b22e3b9b51508025aa75840cd19f87f2947
MD5 042aa5aa20f9e818ca341318262561e7
BLAKE2b-256 79725e0312824abedc866cf9df550e7c24d1ce8571a105b4c2752aa3f4977234

See more details on using hashes here.

File details

Details for the file titanarchive-2.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: titanarchive-2.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 867.6 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for titanarchive-2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4ee7400690b4ca449076ff9d20405aaed9bead68a87e7e2f1e2c9254976737cb
MD5 e5c79b5f69b02c093663e976b316d5f9
BLAKE2b-256 403013cb1870eb845cb667606bbec8d62586f0b9c6fe698729960877c9483ff6

See more details on using hashes here.

File details

Details for the file titanarchive-2.1-py3-none-win32.whl.

File metadata

  • Download URL: titanarchive-2.1-py3-none-win32.whl
  • Upload date:
  • Size: 784.6 kB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for titanarchive-2.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 17ff8df2d981c590dcb9ffa4c4c490f0ccfe66b0b1d099335e22c9cb120fe622
MD5 84268f1bf1234929a8cffc5cd3698697
BLAKE2b-256 2e1edb111c3c93a3156ab23a6c7cd1056e9cd6e7cbf7eaec7b09400c5b47608b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page