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>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>NAND_RESULT_OK<br> NAND_RESULT_ACCESS<br> NAND_RESULT_ALLOC_FAILED<br> NAND_RESULT_AUTHENTICATION<br> NAND_RESULT_BUSY<br> NAND_RESULT_CORRUPT<br> NAND_RESULT_ECC_CRIT<br> NAND_RESULT_EXISTS<br> NAND_RESULT_INVALID<br> NAND_RESULT_MAXBLOCKS<br> NAND_RESULT_MAXFD<br> NAND_RESULT_MAXFILES<br> NAND_RESULT_NOEXISTS<br> NAND_RESULT_UNKNOWN<br> NAND_RESULT_FATAL_ERROR<br></code>
56</p>
57</p>
58
59<H2>Description</H2>
60<p>
61Opens 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>-related functions are applied.
62</p>
63<p>
64<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>
65</p>
66
67<p>
68This function sometimes puts the current thread to sleep, so it cannot be called from callback functions. For precautions when calling similar functions, refer to <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>.
69</p>
70
71<p>
72When <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.
73</p>
74
75<h2>See Also</h2>
76<p class="reference">
77<a href="./NANDSimpleSafeOpenAsync.html">NANDSimpleSafeOpenAsync</a><BR><a href="./NANDSimpleSafeClose.html">NANDSimpleSafeClose</a><BR><a href="./NANDSimpleSafeCloseAsync.html">NANDSimpleSafeCloseAsync</a><BR><a href="./NANDSimpleSafeCancel.html">NANDSimpleSafeCancel</a><BR><a href="./NANDSimpleSafeCancelAsync.html">NANDSimpleSafeCancelAsync</a><BR> <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>
78</p>
79
80<H2>Revision History</H2>
81<p>
822008/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>
83</p>
84
85<hr><p>CONFIDENTIAL</p></body>
86</html>