> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XPersistentLocalStorageMountForPackage

> XPersistentLocalStorageMountForPackage

# XPersistentLocalStorageMountForPackage

Mounts the persistent local storage (PLS) of the specified package as a read-only disc.

## Syntax

```cpp theme={null}
HRESULT XPersistentLocalStorageMountForPackage (   
         const char* packageIdentifier,   
         XPackageMountHandle* mountHandle 
) 
```

### Parameters

*packageIdentifier*   \_In\_\
Type: char\*

A string that uniquely identifies the store package to which the PLS belongs. For more information about package identifiers, see [Manage and license downloadable content (DLC)](/publishing/xstore-commerce/xstore-dlc).

*mountHandle*   \_Out\_writes\_to\_(pathSize,*pathUsed)\
Type: XPackageMountHandle*

The mount handle for the disc where the PLS was mounted.

### Return value

Type: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

Returns **S\_OK** if successful; otherwise, returns an error code. For a list of error codes, see [Error Codes](/reference/errorcodes). If the function fails because the PLS for the specified title does not exist, it will be set to **FILE\_NOT\_FOUND**. If the function fails because it tries to access the PLS of a title that has not enabled shareable persistent local storage, then it will get **ACCESS\_DENIED**.

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

For a title to support shareable PLS, it needs to declare as such in MicrosoftGame.config. More details about Shareable Persistent Local Storage are found in [Local Storage](/build/console-features/storage/local-storage)

<Note>If a title marks the PLS as shareable, then it should make sure that before suspending the game, it closes all the handles to its PLS, otherwise the game suspend will fail and the game will be terminated.</Note>

The following code snippet shows an example of accessing the Shareable PLS of another title.

```cpp theme={null}

HRESULT MountPersistentLocalStorageForPackage(char* packageIdentifier) 
{      
    XPackageMountHandle* mountHandle; 
    HRESULT hr = XPersistentLocalStorageMountForPackage (packageIdentifier, &mountHandle); 

    if (FAILED(hr)) return hr; 
    size_t pathSize; 
    hr = XGetMountPathSize(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("PLS %s mounted at path %s\n", packageIdentifier, path); 
    delete[] path; 
 
    // Unmounts PLS path if this is the last handle 
    // to it. 
    XPackageCloseMountHandle(mountHandle); 
    return S_OK; 
} 

```

## Requirements

**Header:** XPersistentLocalStorage.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XPersistentLocalStorage](/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members)\
[How to use the new MicrosoftGame.config file](/build/core-features/common/game-config/MicrosoftGameConfig-toc)\
[Local Storage](/build/console-features/storage/local-storage)


## Related topics

- [XPersistentLocalStorage](/reference/system/xpersistentlocalstorage/xpersistentlocalstorage_members.md)
- [[DEPRECATED] XPackageMount](/reference/system/xpackage/functions/xpackagemount.md)
- [XPackageGetMountPath](/reference/system/xpackage/functions/xpackagegetmountpath.md)
- [XPersistentLocalStorageSpaceInfo](/reference/system/xpersistentlocalstorage/structs/xpersistentlocalstoragespaceinfo.md)
- [XPersistentLocalStorageGetPath](/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath.md)
