1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" /> 7 <style type="text/css"><!-- 8 span.static_style 9 { 10 font-size : 8pt; 11 color : white; 12 font-weight : bold; 13 background : #44f; 14 border-left : solid 1px #aaf; 15 border-top : solid 1px #aaf; 16 border-right : solid 1px #00c; 17 border-bottom : solid 1px #00c; 18 padding-left : 2px; 19 padding-right : 2px; 20 } 21 22 span.virtual_style 23 { 24 font-size : 8pt; 25 color : white; 26 font-weight : bold; 27 background : #0a0; 28 border-left : solid 1px #0f0; 29 border-top : solid 1px #0f0; 30 border-right : solid 1px #060; 31 border-bottom : solid 1px #060; 32 padding-left : 2px; 33 padding-right : 2px; 34 } 35 36 span.protected_style 37 { 38 font-size : 8pt; 39 color : white; 40 font-weight : bold; 41 background : #444; 42 border-left : solid 1px #ccc; 43 border-top : solid 1px #ccc; 44 border-right : solid 1px #222; 45 border-bottom : solid 1px #222; 46 padding-left : 2px; 47 padding-right : 2px; 48 } 49 --></style> 50<title>nn::fs::FileOutputStream</title> 51 </head> 52 <body> 53<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/fs/Overview.html">fs</a>::FileOutputStream</CODE> Class</h1> 54<h2>Syntax</h2> 55 <div class="section"> 56 <pre class="definition">class FileOutputStream : <br /> private nn::fs::IOutputStream,<br /> private nn::fs::detail::FileBase,<br /> private <a href="../../../nn/util/NonCopyable/Overview.html">nn::util::NonCopyable< FileOutputStream ></a></pre> 57 </div> 58<h2>Description</h2> 59 <div class="section"> 60<p>Class for writing to files.</p><p>Open a file specified by a path name and write data to it.</p><p>To improve the efficiency of writing to files, if the <a href="../../../nn/fs/FileOutputStream/TryWrite.html">TryWrite</a> or <a href="../../../nn/fs/FileOutputStream/Write.html">Write</a> functions are called with flush = false, physical storage itself will not actually be written. Instead, write data will temporarily be saved in a buffer managed by the system. To actually write to physical storage (flush the buffer), call these write functions with flush = true. Then, either indicate that the buffer should be flushed after data is written or explicitly flush it by calling <a href="../../../nn/fs/FileOutputStream/TryFlush.html">TryFlush</a>. If a file is closed by executing the <a href="../../../nn/fs/FileOutputStream/Finalize.html">Finalize</a> function or a destructor, without flushing this buffer, programs will stop if using other than Release version libraries. Plans call for changing this in the next SDK, so that programs will stop even in the case of Release versions.</p><p>If writing the same file consecutively more than once, after writing is finished using flush = false for efficiency, be sure to finally call <a href="../../../nn/fs/FileOutputStream/TryFlush.html">TryFlush</a>.</p><p>You can specify path names using both wide strings and multibyte strings. If you specify a multibyte string, a buffer for conversion to wide characters will be allocated on the stack. Be careful with conversions to wide characters, though, because they are not thread-safe. You should use a wide string unless you have a specific reason not to.</p><p>This class cannot be used to create new files in expanded save data. For that, use a <a href="../../../nn/fs/TryCreateFile.html"><CODE>TryCreateFile</CODE></A> function that specifies the size.</p><h3>Limitations</h3><div class="section"> 61When writing to a file, performance will degrade enormously if the write position and buffer alignment do not match.<br />We recommend writing to files in multiples of four bytes and also aligning your buffer on a multiple of four bytes. 62 </div></div> 63 <a name="function" id="function"> 64<h2>Member Functions</h2> 65 <div class="section"> 66 <table class="members"> 67 <tr> 68 <td width="100"> </td> 69 <th> 70<a href="../../../nn/fs/FileOutputStream/FileOutputStream.html"><CODE>FileOutputStream</CODE></a> 71 </th> 72<td>Constructor.</td> 73 </tr> 74 <tr> 75 <td width="100"> </td> 76 <th> 77<a href="../../../nn/fs/FileOutputStream/Initialize.html"><CODE>Initialize</CODE></a> 78 </th> 79<td>Opens the specified file.</td> 80 </tr> 81 <tr> 82 <td width="100"> </td> 83 <th> 84<a href="../../../nn/fs/FileOutputStream/TryInitialize.html"><CODE>TryInitialize</CODE></a> 85 </th> 86<td>Opens the specified file.</td> 87 </tr> 88 <tr> 89 <td width="100"> </td> 90 <th> 91<a href="../../../nn/fs/FileOutputStream/Finalize.html"><CODE>Finalize</CODE></a> 92 </th> 93<td>Closes a file.</td> 94 </tr> 95 <tr> 96<td width="100"> <span class="virtual_style" title="virtual">V</span> 97 </td> 98 <th> 99<a href="../../../nn/fs/FileOutputStream/~FileOutputStream.html"><CODE>~FileOutputStream</CODE></a> 100 </th> 101<td>Destructor.</td> 102 </tr> 103 <tr> 104<td width="100"> <span class="virtual_style" title="virtual">V</span> 105 </td> 106 <th> 107<a href="../../../nn/fs/FileOutputStream/Write.html"><CODE>Write</CODE></a> 108 </th> 109<td>Writes the specified amount of data from a buffer to a file.</td> 110 </tr> 111 <tr> 112<td width="100"> <span class="virtual_style" title="virtual">V</span> 113 </td> 114 <th> 115<a href="../../../nn/fs/FileOutputStream/TryWrite.html"><CODE>TryWrite</CODE></a> 116 </th> 117<td>Writes the specified amount of data from a buffer to a file.</td> 118 </tr> 119 <tr> 120<td width="100"> <span class="virtual_style" title="virtual">V</span> 121 </td> 122 <th> 123<a href="../../../nn/fs/FileOutputStream/Seek.html"><CODE>Seek</CODE></a> 124 </th> 125<td>Changes the access position in the file.</td> 126 </tr> 127 <tr> 128<td width="100"> <span class="virtual_style" title="virtual">V</span> 129 </td> 130 <th> 131<a href="../../../nn/fs/FileOutputStream/TrySeek.html"><CODE>TrySeek</CODE></a> 132 </th> 133<td>Changes the access position in the file.</td> 134 </tr> 135 <tr> 136<td width="100"> <span class="virtual_style" title="virtual">V</span> 137 </td> 138 <th> 139<a href="../../../nn/fs/FileOutputStream/GetPosition.html"><CODE>GetPosition</CODE></a> 140 </th> 141<td>Gets the current write position relative to the start of the file.</td> 142 </tr> 143 <tr> 144<td width="100"> <span class="virtual_style" title="virtual">V</span> 145 </td> 146 <th> 147<a href="../../../nn/fs/FileOutputStream/TryGetPosition.html"><CODE>TryGetPosition</CODE></a> 148 </th> 149<td>Gets the current write position relative to the start of the file.</td> 150 </tr> 151 <tr> 152<td width="100"> <span class="virtual_style" title="virtual">V</span> 153 </td> 154 <th> 155<a href="../../../nn/fs/FileOutputStream/SetPosition.html"><CODE>SetPosition</CODE></a> 156 </th> 157<td>Sets the current write position relative to the start of the file.</td> 158 </tr> 159 <tr> 160<td width="100"> <span class="virtual_style" title="virtual">V</span> 161 </td> 162 <th> 163<a href="../../../nn/fs/FileOutputStream/TrySetPosition.html"><CODE>TrySetPosition</CODE></a> 164 </th> 165<td>Sets the current write position relative to the start of the file.</td> 166 </tr> 167 <tr> 168<td width="100"> <span class="virtual_style" title="virtual">V</span> 169 </td> 170 <th> 171<a href="../../../nn/fs/FileOutputStream/GetSize.html"><CODE>GetSize</CODE></a> 172 </th> 173<td>Gets the file size.</td> 174 </tr> 175 <tr> 176<td width="100"> <span class="virtual_style" title="virtual">V</span> 177 </td> 178 <th> 179<a href="../../../nn/fs/FileOutputStream/TryGetSize.html"><CODE>TryGetSize</CODE></a> 180 </th> 181<td>Gets the file size.</td> 182 </tr> 183 <tr> 184<td width="100"> <span class="virtual_style" title="virtual">V</span> 185 </td> 186 <th> 187<a href="../../../nn/fs/FileOutputStream/SetSize.html"><CODE>SetSize</CODE></a> 188 </th> 189<td>Sets the file size.</td> 190 </tr> 191 <tr> 192<td width="100"> <span class="virtual_style" title="virtual">V</span> 193 </td> 194 <th> 195<a href="../../../nn/fs/FileOutputStream/TrySetSize.html"><CODE>TrySetSize</CODE></a> 196 </th> 197<td>Sets the file size.</td> 198 </tr> 199 <tr> 200<td width="100"> <span class="virtual_style" title="virtual">V</span> 201 </td> 202 <th> 203<a href="../../../nn/fs/FileOutputStream/Flush.html"><CODE>Flush</CODE></a> 204 </th> 205<td>Writes the file cache back to the device.</td> 206 </tr> 207 <tr> 208<td width="100"> <span class="virtual_style" title="virtual">V</span> 209 </td> 210 <th> 211<a href="../../../nn/fs/FileOutputStream/TryFlush.html"><CODE>TryFlush</CODE></a> 212 </th> 213<td>Writes the file cache back to the device.</td> 214 </tr> 215 <tr> 216 <td width="100"> </td> 217 <th> 218<a href="../../../nn/fs/FileOutputStream/SetPriority.html"><CODE>SetPriority</CODE></a> 219 </th> 220<td>Sets a stream's access priority.</td> 221 </tr> 222 <tr> 223 <td width="100"> </td> 224 <th> 225<a href="../../../nn/fs/FileOutputStream/TrySetPriority.html"><CODE>TrySetPriority</CODE></a> 226 </th> 227<td>Sets a stream's access priority.</td> 228 </tr> </table> 229 </div> 230 </a> 231<h2>Class Hierarchy</h2> 232 <div class="section"> 233<p class="hierarchy"><span>nn::fs::IPositionable</span><br /> <span>nn::fs::IOutputStream</span><br /> <b>nn::fs::FileOutputStream</b> 234 </p> 235 </div> 236<h2>Revision History</h2> 237 <div class="section"> 238 <dl class="history"> 239 <dt>2012/01/23</dt> 240<dd>Added description of flushing the buffer.<BR> 241 </dd> 242 <dt>2011/11/08</dt> 243<dd>Noted that conversions to wide strings are not thread-safe.<br /> 244 </dd> 245 <dt>2011/10/12</dt> 246<dd>Added functions for setting access priorities.<br /> 247 </dd> 248 <dt>2011/03/14</dt> 249<dd>Added note about limitation of write position and buffer alignment.<br /> 250 </dd> 251 <dt>2010/01/29</dt> 252<dd>Initial version.<br /> 253 </dd> 254 </dl> 255 </div> 256 <hr><p>CONFIDENTIAL</p></body> 257</html>