Compartir a través de


XPackageEnumerateChunkAvailability

Examines the installation package and enumerates the availability of all chunks that match the specified selectors.

Syntax

HRESULT XPackageEnumerateChunkAvailability(  
         const char* packageIdentifier,  
         XPackageChunkSelectorType type,  
         void* context,  
         XPackageChunkAvailabilityCallback* callback  
)  

Parameters

packageIdentifier   _In_z_
Type: char*

A string that uniquely identifies the installed package on the disk. For more information about package identifiers, see Manage and license downloadable content (DLC).

type   _In_
Type: XPackageChunkSelectorType

The type of attributes to be enumerated.

context   _In_
Type: void*

The context to be passed to the callback specified in the callback parameter.

callback   _In_
Type: XPackageChunkAvailabilityCallback*

A callback to be called on completion.

Return value

Type: HRESULT

HRESULT success or error code.

Remarks

Note

This function isn't safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.

XPackageEnumerateChunkAvailability is used to examine the package and to enumerate the availability of all selectors of a particular type. For example, calling this with XPackageChunkSelectorType::Language will enumerate all language attributes in the package, as well as their availability.

In the example below, a game will show all the languages it supports and will allow the user to install or remove a language. To do this, the game will query the package to determine which languages are available and whether they are installed.

HRESULT GetPackageLanguages(_Out_ std::map<std::string, bool>& languages)
{
    char id[XPACKAGE_IDENTIFIER_MAX_LENGTH];

    HRESULT hr = XPackageGetCurrentProcessPackageIdentifier(_countof(id), id);
    if (FAILED(hr)) return hr;

    hr = XPackageEnumerateChunkAvailability(id,
        XPackageChunkSelectorType::Language, &languages,
        [](void* context, const XPackageChunkSelector* sel, XPackageChunkAvailability av)
    {
        auto languages = static_cast<std::map<std::string, bool>*>(context);
        switch (av)
        {
        case XPackageChunkAvailability::Ready:
        case XPackageChunkAvailability::Pending:
            languages->emplace(sel->language, true);
            break;

        case XPackageChunkAvailability::Installable:
            languages->emplace(sel->language, false);
            break;

        case XPackageChunkAvailability::Unavailable:
        default:
            break;
        }
        return true;
    });

    return hr;
}

Requirements

Header: XPackage.h

Library: xgameruntime.lib

Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles

See also

XPackage
Streaming Installation and Intelligent Delivery