CNTRead

Syntax


#include <revolution/cnt.h>

s32 CNTRead(CNTFileInfo* cf, void* addr, u32 length);

Arguments

cf Pointer to the CNTFileInfo structure.
addr Pointer to the write destination for the data that was loaded. The write buffer must be 32-byte aligned.
length Number of bytes to load. Must be a multiple of 32.

Return Values

Returns the size (in bytes) successfully loaded when the process completes normally.
Returns one of the following codes when the process fails.

CNT_RESULT_AUTHENTICATION
CNT_RESULT_CORRUPT
CNT_RESULT_ECC_CRIT
CNT_RESULT_INVALD
CNT_RESULT_OUT_OF_MEMORY
CNT_RESULT_UNKNOWN
CNT_RESULT_FATAL

If a fatal error occurs during loading when a disc application is being executed, the function will return CNT_RESULT_READ_ERR. If the load is canceled, the function returns CNT_RESULT_DVD_CANCELED.

Description

Reads and loads the files in the content file. After reading the files, the file access position moves by the amount of data read.

Note:

Differences Between Disc and NAND Access

Note that in the cases outlined below, the behavior is different depending on whether the disc or NAND is being accessed.

Loading data in excess of the file size (although file size is rounded up for 32-byte alignment)

When accessing a disc, the process involves access of individual files, so invalid references out of the file range generates an error. When accessing NAND, the process involves access of files inside the archive file, so there is no error. The portion in excess of the file size is loaded as another file in the archive.

Loading the last file of the archive file

The end of the archive file is not 32-byte aligned. For this reason, if the size of the file located at the end of the archive is not a multiple of 32 bytes, then the value returned when accessing a disc is the size of the specified file after being aligned to 32 bytes. When accessing NAND, however, the value returned is the actual, successfully loaded size (not 32 byte-aligned).

See Also

CNTOpen
CNTSeek
CNTTell
CNTReadWithOffset
Interrupts and Callback Functions
Notes Regarding Read/Writes to Wii Console NAND Memory

Revision History

2009/12/02 Added the Notes Regarding Read/Writes to Wii Console NAND Memory information.
2009/04/15 Added note about the difference between disc and NAND access.
2009/04/07 Revised the description of Return Values.
2008/01/11 Changed the specifications of CNTRead.
2007/11/20 Added information about the result code used with disc applications. Standardized the use of the term "content file".
2007/09/12 Added information about the sleep status of threads.
2006/12/04 Added result code descriptions.
2006/09/20 Added a description about the restrictions when specifying offset.
2006/09/08 Revised the description of the offset argument, which was insufficient.
2006/08/15 Initial version.


CONFIDENTIAL