NANDSimpleSafeOpen

C Specification


#include <revolution/nand.h>

#define NAND_ACCESS_READ       0x01
#define NAND_ACCESS_WRITE      0x02
#define NAND_ACCESS_RW         (NAND_ACCESS_READ | NAND_ACCESS_WRITE)

s32 NANDSimpleSafeOpen(const char *path, NANDFileInfo *info, u8 accType, void *buf, u32 length);

Arguments

path Name of the file to open.
info Pointer to a NANDFileInfo structure.
accType Access type. Specifies NAND_ACCESS_READ, NAND_ACCESS_WRITE, or NAND_ACCESS_RW.
buf Specifies the leading address of the buffer to be used when copying files. The buffer must be 32-byte aligned.
length Specifies the size of the buffer to be used when copying files. The size must be a multiple of NAND_FSBLOCK_SIZE(16KB).

Return Values

Returns one of the following codes:

NAND_RESULT_OK
NAND_RESULT_ACCESS
NAND_RESULT_ALLOC_FAILED
NAND_RESULT_AUTHENTICATION
NAND_RESULT_BUSY
NAND_RESULT_CORRUPT
NAND_RESULT_ECC_CRIT
NAND_RESULT_EXISTS
NAND_RESULT_INVALID
NAND_RESULT_MAXBLOCKS
NAND_RESULT_MAXFD
NAND_RESULT_MAXFILES
NAND_RESULT_NOEXISTS
NAND_RESULT_UNKNOWN
NAND_RESULT_FATAL_ERROR

Description

Opens a file in a manner that guarantees the atomic nature of file updates. The file opened using this function must be closed using NANDSimpleSafeClose or NANDSimpleSafeCloseAsync. Appropriate permissions (both read and write) must be set for the parent directory of the file where the NANDSimpleSafe type function is applied.

This function cannot be used to open more than one file that has the same file name (for example, attempting to save ~/userA/save.dat and ~/userB/save.dat at the same time will return NAND_RESULT_EXISTS).

This function may put the current thread to sleep. For precautions when calling similar functions, refer to Interrupts and Callback Functions.

See Also

NANDSimpleSafeOpenAsync, NANDSimpleSafeClose, NANDSimpleSafeCloseAsync, NANDSimpleSafeCancel, NANDSimpleSafeCancelAsync, Interrupts and Callback Functions

Revision History

2007/09/25 Added information on the sleep status of threads.
2007/05/09 Initial version.


CONFIDENTIAL