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=windows-1252">
6<META http-equiv="Content-Style-Type" content="text/css">
7<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
8<title>NANDSafeOpen</title>
9</head>
10
11<body>
12
13<h1>NANDSafeOpen</h1>
14<p>
15<font color="ff0000">We do not recommend the use of this function. If possible, consider using <CODE>NANDSimpleSafe</CODE>-related functions.</font>
16</p>
17
18<h2>Syntax</h2>
19<dl><dd><pre class="construction">#include &lt;revolution/nand.h&gt;
20
21#define NAND_ACCESS_READ       0x01
22#define NAND_ACCESS_WRITE      0x02
23#define NAND_ACCESS_RW         (NAND_ACCESS_READ | NAND_ACCESS_WRITE)
24
25s32 NANDSafeOpen(const char *path, NANDFileInfo *info, u8 accType, void *buf, u32 length);
26</pre></dd></dl>
27
28<h2>Arguments</h2>
29<p>
30<TABLE class="arguments" border="1" >
31  <tr>
32<TH><code><EM><STRONG>path</STRONG></EM></code></TH>
33<TD>File name to open.</TD>
34  </tr>
35  <tr>
36<TH>info</TH>
37<TD>Pointer to a <CODE>NANDFileInfo</CODE> structure.</TD>
38  </tr>
39  <tr>
40<TH>accType</TH>
41<TD>Access type. Specifies either <code>NAND_ACCESS_READ</code>, <code>NAND_ACCESS_WRITE</code> or <CODE>NAND_ACCESS_RW</CODE>.</TD>
42  </tr>
43  <tr>
44<TH>buf</TH>
45<TD>Specifies the leading address of the buffer to be used when copying files. The buffer must be 32-byte aligned.</TD>
46  </tr>
47  <tr>
48<TH>length</TH>
49<TD>Specifies the size of the buffer to be used when copying files. Buffer size must be a multiple of 32 bytes. We recommend a size between 4 KB and 16 KB.</TD>
50  </tr>
51</TABLE>
52</p>
53
54<h2>Return Values</h2>
55<p>
56Returns one of the following codes.
57<p>
58<code>
59NAND_RESULT_OK<br>
60NAND_RESULT_ACCESS<br>
61NAND_RESULT_ALLOC_FAILED<br>
62NAND_RESULT_AUTHENTICATION<br>
63NAND_RESULT_BUSY<br>
64NAND_RESULT_CORRUPT<br>
65NAND_RESULT_ECC_CRIT<br>
66NAND_RESULT_INVALID<br>
67NAND_RESULT_MAXBLOCKS<br>
68NAND_RESULT_MAXFD<br>
69NAND_RESULT_MAXFILES<br>
70NAND_RESULT_NOEXISTS<br>
71NAND_RESULT_UNKNOWN<br>
72NAND_RESULT_FATAL_ERROR<br>
73</code>
74</p>
75</p>
76
77<H2>Description</H2>
78<p>
79Opens a file in a manner that guarantees the atomic nature of file updates. The file opened using this function must be closed using <code><a href="./NANDSafeClose.html">NANDSafeClose</a></code> or <code><a href="./NANDSafeCloseAsync.html">NANDSafeCloseAsync</a></code>. Appropriate permissions (both read and write) must be set for the parent directory of the file to which <CODE>NANDSafe</CODE>-type functions are applied.
80</p>
81
82<p>
83This function may put the current thread to sleep. For precautions when calling similar functions, refer to <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>.
84</p>
85
86<p>
87When <code>NAND_ACCESS_WRITE</code> or <code>NAND_ACCESS_RW</code> is specified for <code>accType</code>, this function will update the FAT in Wii console NAND memory.
88</p>
89
90<h2>See Also</h2>
91<p class="reference">
92<a href="./NANDSafeOpenAsync.html">NANDSafeOpenAsync</a>,
93<a href="./NANDSafeClose.html">NANDSafeClose</a>,
94<a href="./NANDSafeCloseAsync.html">NANDSafeCloseAsync</a>,
95<a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>
96</p>
97
98<H2>Revision History</H2>
99<p>
1002008/08/01 Added an explanation related to FAT updates.<br>2007/09/25 Added information about the sleep status of threads.<br>2007/05/09 Noted that the use of this function is not recommended.<br>2006/11/30 Added the <CODE>NAND_RESULT_ALLOC_FAILED</CODE> and <CODE>NAND_RESULT_BUSY</CODE> codes.<br>2006/09/08 Added a requirement for the parent directory permissions.<br>2006/08/15 Initial version.<BR>
101</p>
102
103<hr><p>CONFIDENTIAL</p></body>
104</html>