7z Format

7z Format

Support for the 7z and XZ archive formats.

The support includes encrypted archives and all common compression methods.

The 7z Format package is exposed to the SDK:

from Pro.Core import *
from Pkg.SevenZip import *

def parse7zArchive(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = SevenZipObject()
    if not obj.Load(c) or not obj.ParseArchive():
        return
    n = obj.GetEntryCount()
    print(n)
    for i in range(n):
        entry = obj.GetEntry(i)
        if entry == None:
            break
        # skip directories
        if obj.IsDirectory(entry):
            continue
        print("file name:", entry.filename)
        # retrieves the file data as NTContainer
        fc = obj.GetEntryData(entry)

To parse an XZ archive:

from Pro.Core import *
from Pkg.XZ import *

def parseXZArchive(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = XZObject()
    if not obj.Load(c) or not obj.ParseArchive():
        return
    # decompresses the archive
    decompressed = obj.Extract()