ISteamRemoteStorage API methods, which write files to the game’s storage folder on the local hard drive and sync them to the cloud. Alternatively, you can make all your reads and writes directly to the computer’s file system, and then use Steam Auto-Cloud to sync the local folder containing the game data to the cloud.
The Microsoft Game Development Kit (GDK) supports both approaches:
- For code-based cloud saves, the GDK offers a simplified wrapper of the more complex
XGameSaveAPI that provides similar functionality to the methods ofISteamRemoteStorage. - For an approach similar to Steam Auto-Cloud, the GDK supports porting previous titles to PC Game Saves with no-code cloud saves, which syncs a designated local folder to the cloud without requiring changes to your file I/O code.
The full, nonwrapped
XGameSave API offers more functionality and flexibility than the simple wrapper. If you need any of that functionality, don’t use the wrapper. Games must not switch between the two or mix API calls from both. For more information about the XGameSave API, see Game saves.File operation comparisons
The following code examples show how to accomplish basic file operations in the Steamworks Remote Storage API and the GDK equivalent. They assume that theprovider variable holds a pointer to an initialized Microsoft::Xbox::Wrappers::GameSave::Provider object.
If you aren’t using the Steam Remote Storage API but instead opted to use Steam Auto-Cloud, replace the Remote Storage API calls with their file system API equivalents.
Reading a file
Steamworks
GDK
Reference documentation
Microsoft.Xbox.Wrappers.XGameSave.Provider.LoadWriting a file
Steamworks
GDK
Reference documentation
Microsoft.Xbox.Wrappers.XGameSave.Provider.SaveDelete a file
On Steam, you can either delete a file in the cloud but keep the local copy (FileForget), or delete a file from both locations (FileDelete). The XGameSave wrapper API doesn’t have an equivalent to FileForget. Its Delete function works like FileDelete in Steamworks.
Steamworks
GDK
Reference documentation
- Microsoft.Xbox.Wrappers.XGameSave.Provider.Delete(std::string)
- Microsoft.Xbox.Wrappers.XGameSave.Provider.Delete(std::string, std::string)
- Microsoft.Xbox.Wrappers.XGameSave.Provider.Delete(std::string, BlobNames)
Get all files
Steamworks
GDK
Reference documentation
- Microsoft.Xbox.Wrappers.XGameSave.Provider.QueryContainers
- Microsoft.Xbox.Wrappers.XGameSave.Provider.QueryContainerBlobs
Check available space
In the following examples,totalBytes is the amount of space your game is given on the cloud storage provider. availableBytes is the amount of free space remaining (that is, availableBytes = totalBytes – bytesUsed).
Steamworks
GDK
Reference documentation
Microsoft.Xbox.Wrappers.XGameSave.Provider.GetQuotaTerminology differences
On Steam, remote storage data is managed as files, which work like files on a local hard drive. To read or write, you specify the file and then get or set the bytes that it contains. In the Microsoft Game Development Kit (GDK), the equivalent of Steam files are blobs. Blobs are grouped together in a structure called a container. A container is a named group of blobs. For example, you can use containers to support multiple save slots per user, with the same file names in each slot. If you don’t need the extra organizational layer that containers provide, place all your blobs (files) in the same container.Container names can’t include spaces. Attempting to access or create a container name that includes a space causes the provider method to return an HRESULT of
0x80830001: the specified volume doesn’t support storage tiers.Storage limits
The Microsoft Game Development Kit (GDK) has a lower maximum blob or file write size and overall storage limit than Steam. On Steam, each file write operation is limited to 100 mebibytes (MiB), and each file can’t be larger than 200 MiB. In contrast, theXGameSave API and its wrapper limit each blob to 16 MB and allow a maximum of 256 MB per user per game.
If you need to store more than 16 MB of data in a blob, split the data into multiple blobs. Then implement a sequential read and write function to process the data one blob at a time.
Wrapper functions are blocking
TheISteamRemoteStorage interface offers two versions of read and write functions: FileRead and FileWrite, plus FileReadAsync and FileWriteAsync. The Async versions call back when the file has been read or written. The simplified XGameSave wrapper functions don’t offer asynchronous versions of its equivalents to FileRead and FileWrite. Provider::Load and Provider::Save are both blocking, so keep this behavior in mind when you use them in your game.
For this reason, Provider::Initialize throws an exception if you call it from the UI thread.
Initialization
Include the header file for the wrapper in your game’s solution before you use any wrapper methods. You can find it at %GRDKLatest%\GameKit\Include\xgamesavewrappers.hpp. Before using theXGameSave wrapper’s methods, create an instance of the Provider class and call the Provider::Initialize method. Hold a pointer to the Provider instance for the lifetime of your game. Call Provider::Initialize from a thread other than the UI thread. The method throws an exception if you call it from the UI thread. To initialize the wrapper provider, you need an XUserHandle for the current user and your game’s service configuration identifier (SCID).
