Freigeben über


XPackageGetMountPathSize

Gets the size required for an array to hold a mount path returned by XPackageGetMountPath.

Syntax

HRESULT XPackageGetMountPathSize(  
         XPackageMountHandle mount,  
         size_t* pathSize  
)  

Parameters

mount   _In_
Type: XPackageMountHandle

The handle to the mounted installation.

pathSize   _Out_
Type: size_t*

On return, contains the size required for an array.

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.

Together, XPackageGetMountPathSize and XPackageGetMountPath are used to return the file path to a package's contents.

XPackageGetMountPath mounts the specified package identifier and returns a mount handle to it. This might take several seconds. For more information about package identifiers, see Manage and license downloadable content (DLC).

Only content packages can be mounted. An attempt to mount another game will yield E_ACCESS_DENIED.

The following code example shows how packages are usually mounted:

HRESULT MountDlc(char* dlcIdentifier)
{
    XPackageMountHandle mountHandle;
    HRESULT hr = XPackageMount(dlcIdentifier, &mountHandle);
    if (FAILED(hr)) return hr;

    size_t pathSize;
    hr = XPackageGetMountPathSize(mountHandle, &pathSize);
    if (FAILED(hr))
    {
        XPackageCloseMountHandle(mountHandle);
        return hr;
    }

    char* path = new (std::nothrow) char[pathSize];
    if (path == nullptr)
    {
        XPackageCloseMountHandle(mountHandle);
        return E_OUTOFMEMORY;
    }

    hr = XPackageGetMountPath(mountHandle, pathSize, path);
    if (FAILED(hr))
    {
        XPackageCloseMountHandle(mountHandle);
        delete[] path;
        return hr;
    }

    printf("Dlc %s mounted at path %s\n", dlcIdentifier, path);

    delete[] path;

    // Unmounts DLC path if this is the last handle
    // to it.
    XPackageCloseMountHandle(mountHandle);
    return S_OK;
}

Requirements

Header: XPackage.h

Library: xgameruntime.lib

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

See also

XPackage
How to create and use Downloadable Content Packages (DLC) for PC and Xbox One
XPackageGetMountPath