Pkg.XAR — API for parsing XAR archives

Overview

The Pkg.XAR module contains the API for parsing XAR archives.

Parsing an XAR Archive

The following code example demonstrates how to parse an XAR archive:

from Pro.Core import *
from Pkg.XAR import *

def parseXARArchive(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = XARObject()
    if not obj.Load(c) or not obj.ParseArchive():
        return
    entry = None
    while entry := obj.NextEntry(entry):
        # skip directories
        if obj.IsDirectory(entry):
            continue
        print("file name:", entry.path)
        # retrieves the file data as NTContainer
        fc = obj.GetEntryData(entry)

Module API

Pkg.XAR module API.

Classes:

XARFileEntry()

This class represents a file entry in a XAR archive.

XARObject()

This class represents an XAR archive.

class XARFileEntry

This class represents a file entry in a XAR archive.

class XARObject

Bases: Pro.Core.CFFObject

This class represents an XAR archive.

Methods:

GetCreationTime()

Returns the creation time if available; otherwise returns an invalid date-time.

GetEntryData(entry[, wo])

Retrieves the data of an entry.

GetEntryRange(entry)

Returns the range of the entry as a tuple of offset and size.

GetHeader()

Returns the header structure.

GetHeaderSize()

Returns the header size.

GetToCChecksumRange()

Returns the checksum range of the ToC as a tuple of offset and size.

GetToCSize()

Returns the (compressed) ToC size.

IsDirectory(entry)

Checks whether an entry is a directory.

NextEntry(curentry)

Iterates over the entries.

ParseArchive([wo])

Parses the archive.

VerifyEntryChecksum(entry[, wo])

Verifies the checksum of an entry.

GetCreationTime()Pro.Core.NTDateTime
Returns

Returns the creation time if available; otherwise returns an invalid date-time.

Return type

NTDateTime

GetEntryData(entry: Pkg.XAR.XARFileEntry, wo: Optional[Pro.Core.NTIWait] = None)Pro.Core.NTContainer

Retrieves the data of an entry.

Parameters
  • entry (XARFileEntry) – The entry.

  • wo (Optional[NTIWait]) – An optional wait object for the operation.

Returns

Returns the data if successful; otherwise returns an invalid container.

Return type

NTContainer

See also NextEntry() and GetEntryRange().

GetEntryRange(entry: Pkg.XAR.XARFileEntry)Tuple[int, int]
Returns

Returns the range of the entry as a tuple of offset and size.

Return type

Tuple[int, int]

See also NextEntry() and GetEntryData().

GetHeader()Pro.Core.CFFStruct
Returns

Returns the header structure.

Return type

CFFStruct

GetHeaderSize()int
Returns

Returns the header size.

Return type

int

GetToCChecksumRange()Tuple[int, int]
Returns

Returns the checksum range of the ToC as a tuple of offset and size.

Return type

Tuple[int, int]

GetToCSize()int
Returns

Returns the (compressed) ToC size.

Return type

int

IsDirectory(entry: Pkg.XAR.XARFileEntry)

Checks whether an entry is a directory.

Parameters

entry (XARFileEntry) – The entry.

Returns

Returns True if the entry is a directory; otherwise returns False.

Return type

bool

See also NextEntry().

NextEntry(curentry: Optional[Pkg.XAR.XARFileEntry])Optional[Pkg.XAR.XARFileEntry]

Iterates over the entries.

Parameters

curentry (Optional[XARFileEntry]) – The current entry.

Returns

Returns the next entry if available; otherwise returns None.

Return type

Optional[XARFileEntry]

See also GetEntryData().

ParseArchive(wo: Optional[Pro.Core.NTIWait] = None)bool

Parses the archive.

Parameters

wo (Optional[NTIWait]) – Optional wait object for the parsing operation.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

VerifyEntryChecksum(entry: Pkg.XAR.XARFileEntry, wo: Optional[Pro.Core.NTIWait] = None)bool

Verifies the checksum of an entry.

Parameters
  • entry (XARFileEntry) – The entry.

  • wo (Optional[NTIWait]) – An optional wait object for the operation.

Returns

Returns True if the checksum is correct; otherwise returns False.

Return type

bool

See also NextEntry() and GetEntryData().