SAVEOpenFile / SAVEOpenFileAsync

Syntax

#include <nn/save.h>

FSStatus            SAVEOpenFile(
                        FSClient                *client,
                        FSCmdBlock              *block,
                        u8                      accountSlotNo,
                        const char              *path,
                        const char              *mode,
                        FSFileHandle            *fileHandle,
                        FSRetFlag               errHandling
                        );
FSStatus            SAVEOpenFileAsync(
                        FSClient                *client,
                        FSCmdBlock              *block,
                        u8                      accountSlotNo,
                        const char              *path,
                        const char              *mode,
                        FSFileHandle            *fileHandle,
                        FSRetFlag               errHandling,
                        const FSAsyncParams     *asyncParams
                        );

Parameters

client Pointer to the client buffer.
block Command block.
accountSlotNo The user account slot number.
path Path that specifies the quota. The relative path for the save directory for the specified user account. The length must be less than FS_MAX_ARGPATH_SIZE.
mode Short string parameter that specifies the access mode. The length must be less than FS_MAX_MODE_SIZE. The following values can be specified in the parameters:
"r": Open a file for reading. The file must exist.
"w": Create an empty file for writing. If a file with the same name already exists, its content is erased and the file is treated as a new empty file.
"a": Append to a file. Writing operations append data at the end of the file. The file is created if it does not exist.
"r+": Open a file to update both reading and writing. The specified file must exist.
"w+": Create an empty file for both reading and writing. If a file with the same name already exists, its content is erased and the file is treated as a new empty file.
"a+": Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition the internal pointer to anywhere in the file for reading, but writing operations move it back to the end of the file. The file is created if it does not exist.
fileHandle Pointer to the handle of the file stream associated with the file to open.
errHandling Automatic error handling flag. Only the indicated error is returned.
asyncParams (Async API only) Notification parameters for an asynchronous call.

Return Values

Synchronous API: Return Value; Asynchronous API: Callback Return Value

FS_STATUS_OK Successfully completed.
FS_STATUS_CANCELED The command was canceled.
FS_STATUS_MAX System has too many file points to create more.
FS_STATUS_ALREADY_OPEN The file is already open.
You are trying to open the file illegally.
FS_STATUS_NOT_FOUND Target not found.
or
The specified user account does not exist on this Wii U console.
FS_STATUS_NOT_FILE Specified path is not a file.
FS_STATUS_ACCESS_ERROR Access mode is invalid (e.g. specified "r+" for read-only media).
FS_STATUS_PERMISSION_ERROR The caller does not have correct access permission.
FS_STATUS_JOURNAL_FULL Journaling space is full and new journaling block cannot be allocated.
FS_STATUS_STORAGE_FULL Data space cannot be allocated.
FS_STATUS_MEDIA_NOT_READY (Only for manually mounted devices) Media is not present.
FS_STATUS_MEDIA_ERROR (Only for manually mounted devices) Media is in some inaccessible condition.
FS_STATUS_DATA_CORRUPTED (Only for manually mounted devices) The data is corrupted beyond repair. The volume needs format.
FS_STATUS_WRITE_PROTECTED (Only for manually mounted devices) Media is write protected.

Async API: Immediate Return Values

FS_STATUS_OK Successfully issued the request.
FS_STATUS_NOT_FOUND The specified user account does not exist on this Wii U console.
FS_STATUS_FATAL_ERROR The argument is invalid.

Description

Opens the save data file specified in path, and creates the file stream associated with that file. The position of the file stream is set to the beginning. mode is a short string parameter to specify the access mode.

Both the sync and the async style API functions are provided. To use the async API functions, set the user callback and parameters in asyncParams. For more information, see FSAsyncParams.

The generated file handle is stored in fileHandle when completed.

The generated file handle is a positive value (>0) if the function succeeds. Otherwise, the handle value is FS_INVALID_HANDLE_VALUE. The invalid handle value is not necessary to close.

Do Not Call From

SAVEOpenFile

None.

SAVEOpenFileAsync

None.

See Also

File/Directory operations
FSReadFile
FSWriteFile
FSCloseFile

Revision History

2014/10/22 Revised the return values.
2014/01/14 Added FS_STATUS_STORAGE_FULL and FS_STATUS_JOURNAL_FULL to return values.
2013/05/08 Automated cleanup pass.
2012/10/01 Revised the return values.
2012/06/25 Fixed a link in the See Also list.
2012/06/14 Corrected links.
2012/03/29 Initial version.


CONFIDENTIAL