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>C Specification</h2>
16<dl><dd><pre><code>
17#include &lt;revolution/nand.h&gt;
18
19#define NAND_ACCESS_READ       0x01
20#define NAND_ACCESS_WRITE      0x02
21#define NAND_ACCESS_RW         (NAND_ACCESS_READ | NAND_ACCESS_WRITE)
22
23s32 NANDSimpleSafeOpen(const char *path, NANDFileInfo *info, u8 accType, void *buf, u32 length);
24
25</code></pre></dd></dl>
26
27<h2>Arguments</h2>
28<p>
29<TABLE border="1" >
30  <tr>
31<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>path</EM></STRONG></CODE></TD>
32<TD width="520">Name of the file to open.</TD>
33  </tr>
34  <tr>
35<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>info</EM></STRONG></CODE></TD>
36<TD width="520">Pointer to a <CODE>NANDFileInfo</CODE> structure.</TD>
37  </tr>
38  <tr>
39<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>accType</EM></STRONG></CODE></TD>
40<TD width="520">Access type. Specifies <code>NAND_ACCESS_READ</code>, <code>NAND_ACCESS_WRITE</code>, or <CODE>NAND_ACCESS_RW</CODE>.</TD>
41  </tr>
42  <tr>
43<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>buf</EM></STRONG></CODE></TD>
44<TD width="520">Specifies the leading address of the buffer to be used when copying files. The buffer must be 32-byte aligned.</TD>
45  </tr>
46  <tr>
47<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>length</EM></STRONG></CODE></TD>
48<TD width="520">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>(16KB).</font></TD>
49  </tr>
50</TABLE>
51</p>
52
53<h2>Return Values</h2>
54<p>
55Returns one of the following codes:
56<p>
57<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>
58</p>
59</p>
60
61<H2>Description</H2>
62<p>
63Opens 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="./NANDSimpleSafeClose.html">NANDSimpleSafeClose</a></code> or <code><a href="./NANDSimpleSafeCloseAsync.html">NANDSimpleSafeCloseAsync</a></code>. Appropriate permissions (both read and write) must be set for the parent directory of the file where the NANDSimpleSafe type function is applied.
64</p>
65<p>
66<font color="ff0000">This function cannot be used to open more than one file that has the same file name (for example, attempting to save <code>~/userA/save.dat</code> and <code>~/userB/save.dat</code> at the same time will return <code>NAND_RESULT_EXISTS</code>).</font>
67</p>
68
69<p>
70This 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>.
71</p>
72
73<h2>See Also</h2>
74<p>
75<code><a href="./NANDSimpleSafeOpenAsync.html">NANDSimpleSafeOpenAsync</a></code>, <code><a href="./NANDSimpleSafeClose.html">NANDSimpleSafeClose</a></code>, <code><a href="./NANDSimpleSafeCloseAsync.html">NANDSimpleSafeCloseAsync</a></code>, <code><a href="./NANDSimpleSafeCancel.html">NANDSimpleSafeCancel</a></code>, <code><a href="./NANDSimpleSafeCancelAsync.html">NANDSimpleSafeCancelAsync</a></code>, <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>
76</p>
77
78<H2>Revision History</H2>
79<p>
802007/09/25 Added information on the sleep status of threads.<br>2007/05/09 Initial version. <BR>
81</p>
82
83<hr><p>CONFIDENTIAL</p></body>
84</html>
85