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>NANDSimpleSafeOpen</title>
9</head>
10
11<body>
12
13<h1>NANDSimpleSafeOpen</h1>
14
15<h2>Syntax</h2>
16<dl><dd><pre class="construction">#include &lt;revolution/nand.h&gt;
17
18#define NAND_ACCESS_READ       0x01
19#define NAND_ACCESS_WRITE      0x02
20#define NAND_ACCESS_RW         (NAND_ACCESS_READ | NAND_ACCESS_WRITE)
21
22s32 NANDSimpleSafeOpen(const char *path, NANDFileInfo *info, u8 accType, void *buf, u32 length);
23</pre></dd></dl>
24
25<h2>Arguments</h2>
26<p>
27<TABLE class="arguments" border="1" >
28  <tr>
29<TH>path</TH>
30<TD>Name of the file to open.</TD>
31  </tr>
32  <tr>
33<TH>info</TH>
34<TD>Pointer to a <CODE>NANDFileInfo</CODE> structure.</TD>
35  </tr>
36  <tr>
37<TH>accType</TH>
38<TD>Access type. Specifies either <code>NAND_ACCESS_READ</code>, <code>NAND_ACCESS_WRITE</code> or <CODE>NAND_ACCESS_RW</CODE>.</TD>
39  </tr>
40  <tr>
41<TH>buf</TH>
42<TD>Specifies the leading address of the buffer to be used when copying files. The buffer must be 32-byte aligned.</TD>
43  </tr>
44  <tr>
45<TH>length</TH>
46<TD>Specifies the size of the buffer to be used when copying files. <font color="ff0000">The size must be a multiple of <code>NAND_FSBLOCK_SIZE</code> (16 KB).</font></TD>
47  </tr>
48</TABLE>
49</p>
50
51<h2>Return Values</h2>
52<p>
53Returns one of the following codes.
54<p>
55<code>
56NAND_RESULT_OK<br>
57NAND_RESULT_ACCESS<br>
58NAND_RESULT_ALLOC_FAILED<br>
59NAND_RESULT_AUTHENTICATION<br>
60NAND_RESULT_BUSY<br>
61NAND_RESULT_CORRUPT<br>
62NAND_RESULT_ECC_CRIT<br>
63NAND_RESULT_EXISTS<br>
64NAND_RESULT_INVALID<br>
65NAND_RESULT_MAXBLOCKS<br>
66NAND_RESULT_MAXFD<br>
67NAND_RESULT_MAXFILES<br>
68NAND_RESULT_NOEXISTS<br>
69NAND_RESULT_UNKNOWN<br>
70NAND_RESULT_FATAL_ERROR<br>
71</code>
72</p>
73</p>
74
75<H2>Description</H2>
76<p>
77Opens a file in a manner that guarantees the atomic nature of file updates. The file opened using this function must be closed using either the <code><a href="./NANDSimpleSafeClose.html">NANDSimpleSafeClose</a></code> or the <code><a href="./NANDSimpleSafeCloseAsync.html">NANDSimpleSafeCloseAsync</a></code> function. Appropriate permissions (both read and write) must be set for the parent directory of the file to which <CODE>NANDSimpleSafe</CODE>-type functions are applied.
78</p>
79<p>
80<font color="ff0000">This function cannot simultaneously open multiple files with the same name (for example, <code>~/userA/save.dat</code> and <code>~/userB/save.dat</code>). <code>NAND_RESULT_EXISTS</code> will be returned.</font>
81</p>
82
83<p>
84This 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>.
85</p>
86
87<p>
88When <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.
89</p>
90
91<h2>See Also</h2>
92<p class="reference">
93<a href="./NANDSimpleSafeOpenAsync.html">NANDSimpleSafeOpenAsync</a>,
94<a href="./NANDSimpleSafeClose.html">NANDSimpleSafeClose</a>,
95<a href="./NANDSimpleSafeCloseAsync.html">NANDSimpleSafeCloseAsync</a>,
96<a href="./NANDSimpleSafeCancel.html">NANDSimpleSafeCancel</a>,
97<a href="./NANDSimpleSafeCancelAsync.html">NANDSimpleSafeCancelAsync</a>,
98<a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>
99</p>
100
101<H2>Revision History</H2>
102<p>
1032008/08/01 Added an explanation related to FAT updates.<br>2007/09/25 Added information on the sleep status of threads.<br>2007/05/09 Initial version.<BR>
104</p>
105
106<hr><p>CONFIDENTIAL</p></body>
107</html>