Pkg.AR — API for parsing AR archives

Overview

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

Parsing an AR Archive

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

from Pro.Core import *
from Pkg.AR import *

def parseArArchive(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = ARObject()
    if not obj.Load(c) or not obj.ParseArchive():
        return
    entry = None
    while entry := obj.NextEntry(entry):
        print("Name:", entry.name)
        # retrieves the entry data as NTContainer
        c = obj.GetEntryData(entry)

Module API

Pkg.AR module API.

Classes:

ARHeader()

This class represents a header of an entry in an AR archive.

ARObject()

This class represents an AR archive object.

class ARHeader

This class represents a header of an entry in an AR archive.

Variables
  • offset – The offset of the header in the archive.

  • size – The size of the header.

  • data_offset – The offset where the data of the entry starts.

  • data_size – The size of the data of the entry.

  • name – The name of the entry.

  • date – The date associated with the entry.

  • user_id – The user ID associated with the entry.

  • group_id – The group ID associated with the entry.

  • mode – The mode (permissions) of the entry.

class ARObject

Bases: Pro.Core.CFFObject

This class represents an AR archive object.

Methods:

GetEntryData(entry)

Returns the data associated with an AR archive entry.

NextEntry([entry])

Retrieves the next entry in the AR archive.

ParseArchive()

Parses the AR archive.

GetEntryData(entry)Pro.Core.NTContainer
Returns

Returns the data associated with an AR archive entry.

Return type

NTContainer

See also NextEntry().

NextEntry(entry: Optional[Pkg.AR.ARHeader] = None)Optional[Pkg.AR.ARHeader]

Retrieves the next entry in the AR archive.

Parameters

entry (Optional[ARHeader]) – The previous header entry.

Returns

Returns a header if successful; otherwise returns None.

Return type

Optional[ARHeader]

See also ParseArchive() and GetEntryData().

ParseArchive()bool

Parses the AR archive.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

See also NextEntry() and GetEntryData().