Save Data Handling

Creating a Save Directory

You can create an individual account save directory or common save directory by using the SAVEInitSaveDir function.

Calls to SAVEInitSaveDir take approximately one second. Game applications do not need to call this function if the save directory already exists.

Accessing Save Data

Game applications can create and delete save data using various SAVE functions. These functions abstract the absolute path to save data by getting the account slot number and relative path from the account save directory.

For example, assume the save data file path on NAND is: /vol/storage_mlc01/.../<title_id_hi>/<title_id_lo>/user/common/savefile. Game applications can access save data without needing an absolute path by specifying the account slot number and a relative path as arguments to SAVE functions. (In this example, you would specify ACT_SLOT_NO_COMMON and savefile.)

Creating Save Data Files

Use the SAVEOpenFile function to create a new save data file.

After creating a new save data file, make data transactions by using standard file system (FS) calls (FSWriteFile, FSReadFile, FSCloseFile, and so on).

Creating Subdirectories

Use the SAVEMakeDir function to create a new save data directory.

Removing Save Data Files and Subdirectories

Use the SAVERemove function to remove a save data file or subdirectory.

Files and subdirectories cannot be removed if any file in the specified path is open.

Flushing the Save Directory Quota

To update data safely, save data supports journaling. To finalize changes to save data, flush the save directory quota and finalize changes by calling SAVEFlushQuota. Flushing the save directory quota prevents save data from becoming corrupted if there is an unexpected shutdown or power outage during the update.

If you shut down the application without flushing the quota of the save directory, any unsaved changes in the save directory are discarded. To intentionally discard unsaved changes, call SAVERollbackQuota.

For more information about journaling and quotas, see the SAVE Programming Guide.

PCFS does not support journaling or the concept of quotas.

Removing Save Directories

Use the Save Data Manager menu in the System Config Tool to remove a save directory.

If you accidentally remove the directory specified by $CAFE_SAVE_DIR by another method, you must recreate the directory, and then use this tool to remove it. This prevents inconsistencies in data management.

Revision History

2013/11/21 Remove deprecated and deleted removeSaveData command.
2013/05/08 Automated cleanup pass.
2013/03/06 Cleaned up content.
2011/03/29 Initial version.