Freigeben über


XPackageEstimateDownloadSize

Computes the download size of the chunks that match the specified installation selectors.

Syntax

HRESULT XPackageEstimateDownloadSize(  
         const char* packageIdentifier,  
         uint32_t selectorCount,  
         XPackageChunkSelector* selectors,  
         uint64_t* downloadSize,  
         bool* shouldPresentUserConfirmation  
)  

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).

selectorCount   _In_
Type: uint32_t

The number of selectors in the selectors parameter.

selectors   _In_reads_(selectorCount)
Type: XPackageChunkSelector*

An array of selectors that specify the chunks to be operated on.

downloadSize   _Out_
Type: uint64_t*

On return, contains the download size of the specified installation selectors.

shouldPresentUserConfirmation   _Out_opt_
Type: bool*

If the download would require the user's confirmation, returns true; otherwise, returns false.

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.

If provided, the shouldPresentUserConfirmation parameter will be set to true if the estimated download size is large enough to prompt the user to accept the download size.

The following example accepts a track name for a racing game and, if the track is not installed, prints the download size for the track:

HRESULT ListDownloadSize(char* trackName)
{
    XPackageChunkSelector selector;
    selector.type = XPackageChunkSelectorType::Tag;
    selector.tag = trackName;

    char id[XPACKAGE_IDENTIFIER_MAX_LENGTH];
    HRESULT hr = XPackageGetCurrentProcessPackageIdentifier(_countof(id), id);
    if (FAILED(hr)) return hr;

    XPackageChunkAvailability availability;
    hr = XPackageFindChunkAvailability(id, 1, &selector, &availability);
    if (FAILED(hr)) return hr;

    if (availability == XPackageChunkAvailability::Installable)
    {
        uint64_t downloadSize;
        hr = XPackageEstimateDownloadSize(id, 1, &selector, &downloadSize, nullptr);
        if (FAILED(hr)) return hr;

        printf("Download Size for track %s: %I64u\n", trackName, downloadSize);
    }

    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