1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6<META http-equiv="Content-Style-Type" content="text/css">
7<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
8<title>CNTReadWithOffset</title>
9</head>
10
11<body>
12
13<h1>CNTReadWithOffset</h1>
14
15<h2>Syntax</h2>
16<dl><dd><pre><code>
17#include &lt;revolution/cnt.h&gt;
18
19s32 CNTReadWithOffset(CNTFileInfo* cf, void* addr, u32 length, s32 offset);
20
21#ifdef CNT_READ_BACKWARD_COMPATIBLE
22#define CNTRead CNTReadWithOffset
23#endif
24</code></pre></dd></dl>
25
26<h2>Arguments</h2>
27<p>
28<TABLE border="1" >
29  <tr>
30<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>cf</EM></STRONG></CODE></TD>
31<TD width="520">Pointer to the <CODE>CNTFileInfo</CODE> structure.</TD>
32  </tr>
33  <tr>
34<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>addr</EM></STRONG></CODE></TD>
35<TD width="520">Pointer to the write destination for the data that was loaded. The write buffer must be 32-byte aligned.</TD>
36  </tr>
37  <tr>
38<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>length</EM></STRONG></CODE></TD>
39<TD width="520">Number of bytes to load. Must be a multiple of 32.</TD>
40  </tr>
41  <tr>
42<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>offset</EM></STRONG></CODE></TD>
43<TD width="520">File position to start loading from. Must be a multiple of 4.</TD>
44  </tr>
45</TABLE>
46</p>
47
48<h2>Return Values</h2>
49<p>
50Returns the size (in bytes) successfully loaded when the process completes normally.<br>Returns one of the following codes when the process fails.
51</p>
52
53<p>
54<code>CNT_RESULT_AUTHENTICATION<br> CNT_RESULT_CORRUPT<br> CNT_RESULT_ECC_CRIT<br> CNT_RESULT_INVALD<br> CNT_RESULT_OUT_OF_MEMORY<br> CNT_RESULT_UNKNOWN<br> CNT_RESULT_FATAL<br></code>
55</p>
56
57<p>
58If a fatal error occurs during loading when a disc application is being executed, the function will return <CODE>CNT_RESULT_READ_ERR</CODE>. If the load is canceled, the function returns <code>CNT_RESULT_DVD_CANCELED</code>.
59</p>
60
61<H2>Description</H2>
62<p>
63Reads and loads the files in the content file. The access position in the file does not change after loading. The current file access position is used as the point of reference for the file read position specified in the argument <code><STRONG><EM>offset</EM></STRONG></code>. Note that, unlike <code>DVDRead</code>, the reference position is not always the start of the file. This reference position will change if <code>CNTSeek</code> is executed.
64</p>
65
66<p>
67This function is the same as <code>CNTRead</code> in NADK Version 2.1 and earlier. Since <code>CNTRead</code> is replaced with this function if the macro <code>CNT_READ_BACKWARD_COMPATIBLE</code> is defined, applications created using NADK Version 2.1 or earlier can be ported to this version of NADK without changing function calls.
68</p>
69
70<p><B>Note:</B></p>
71<ul>
72<li>This function sometimes puts the current thread to sleep, so it cannot be called from callback functions. Refer to <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>.</li>
73<li>If, while the <code>CNTReadWithOffset</code> function is processing, certain functions or combinations of functions are called from a different thread, the processing of these other functions may be delayed or even fail. For more information about the occurrence conditions, symptoms, and workarounds, see <a href="../nand/intro.html#NAND RW NOTICE">Notes Regarding Read/Writes to Wii Console NAND Memory</a>.</li>
74</ul>
75
76<H2>Differences Between Disc and NAND Access</H2>
77<p>
78Note that in the cases outlined below, the behavior is different depending on whether the disc or NAND is being accessed.
79</p>
80<h4>Loading data in excess of the file size (although file size will be rounded up for 32-byte alignment)</h4>
81<p>
82When 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.
83</p>
84<h4>Loading the last file of the archive file</h4>
85<p>
86The 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, whereas when accessing NAND the value returned is the actual, successfully loaded size (not 32 byte-aligned).
87</p>
88
89<h2>See Also</h2>
90<p>
91<code><a href="./CNTOpen.html">CNTOpen</a><BR> <a href="./CNTSeek.html">CNTSeek</a><BR> <a href="./CNTTell.html">CNTTell</a><BR> <a href="./CNTRead.html">CNTRead</a><br> <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a><BR> <a href="../nand/intro.html#NAND RW NOTICE">Notes Regarding Read/Writes to Wii Console NAND Memory</a></code>
92</p>
93<H2>Revision History</H2>
94<p>
952009/12/02 Added the <a href="../nand/intro.html#NAND RW NOTICE">Notes Regarding Read/Writes to Wii Console NAND Memory</a> information.<br>2009/04/15 Added note about the difference between disc and NAND access. <br> 2009/04/07 Revised the description of <B>Return Values</B>.<br>2008/01/11 Initial version.
96</p>
97
98
99<hr><p>CONFIDENTIAL</p></body>
100</html>
101