#include <revolution/cnt.h>
s32 CNTInitHandle(u32 contentIdx, CNTHandle* CntHandle, MEMAllocator* allocator);
contentIdx |
The number of the content file you want to open. Must be in the range of 2 to 511. | CntHandle |
Pointer to the CNTHandle structure to be initialized. |
allocator |
Pointer to the memory allocator for storing FST. The allocator must be 32-byte aligned.The memory is released when CNTReleaseHandle is called. |
For a NAND application, returns one of the following codes:
CNT_RESULT_OK
CNT_RESULT_ACCESS
CNT_RESULT_ALLOC_FAILED
CNT_RESULT_AUTHENTICATION
CNT_RESULT_CORRUPT
CNT_RESULT_ECC_CRIT
CNT_RESULT_INVALID
CNT_RESULT_MAXFD
CNT_RESULT_OUT_OF_MEMORY
CNT_RESULT_UNKNOWN
CNT_RESULT_FATAL
For disc applications, returns CNT_RESULT_INVALID if the /content{index} directory does not exist under DvdRoot.
Opens the content file and initializes the CNTHandle structure. Because the application (.elf file) uses Content File No. 1, the content file numbers start from 2.
Once the memory allocator is passed, CNTHandle stores it internally, so the user does not need to pass it to the API again. Be careful not to release the allocator while the program is running. When using multithreads, do not share the CNTHandle structure among threads. Although you can write a program to guarantee that while one thread is accessing a file no other thread can access that file, we recommend using a new CNTHandle structure for each a new thread.
One file descriptor is consumed each time the CNTHandle structure is initialized. This file descriptor is the same file system item as that used in the NAND API. As a result, the number of available CNTHandle structures will decrease when files are open in the NAND API.
You can use the CNTGetFSTSize function to get the size of the heap region you will need for opening the content file.
Note: This function may put the current thread to sleep. Refer to Interrupts and Callback Functions.
CNTGetFSTSize, CNTReleaseHandle, Interrupts and Callback Functions
2008/02/15 Added text about the heap region needed for opening the content file.
2007/11/20 Standardized the use of the term "content file".
2007/10/11 Corrected typos.
2007/09/12 Added information about the sleep status of threads.
2007/04/27 Added a description about the 32-byte alignment of memory allocators.
2006/12/12 Added result code descriptions for disc applications.
2006/12/04 Added a list of result codes.
2006/10/26 Added description of file descriptors.
2006/08/15 Initial version.
CONFIDENTIAL