1e6865dcdSopenharmony_ci<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2e6865dcdSopenharmony_ci<html lang="en">
3e6865dcdSopenharmony_ci<head>
4e6865dcdSopenharmony_ci<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5e6865dcdSopenharmony_ci<meta http-equiv="Content-Style-Type" content="text/css">
6e6865dcdSopenharmony_ci<link rel="up" title="FatFs" href="../00index_e.html">
7e6865dcdSopenharmony_ci<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/write.html">
8e6865dcdSopenharmony_ci<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
9e6865dcdSopenharmony_ci<title>FatFs - f_write</title>
10e6865dcdSopenharmony_ci</head>
11e6865dcdSopenharmony_ci
12e6865dcdSopenharmony_ci<body>
13e6865dcdSopenharmony_ci
14e6865dcdSopenharmony_ci<div class="para func">
15e6865dcdSopenharmony_ci<h2>f_write</h2>
16e6865dcdSopenharmony_ci<p>The f_write writes data to a file.</p>
17e6865dcdSopenharmony_ci<pre>
18e6865dcdSopenharmony_ciFRESULT f_write (
19e6865dcdSopenharmony_ci  FIL* <span class="arg">fp</span>,          <span class="c">/* [IN] Pointer to the file object structure */</span>
20e6865dcdSopenharmony_ci  const void* <span class="arg">buff</span>, <span class="c">/* [IN] Pointer to the data to be written */</span>
21e6865dcdSopenharmony_ci  UINT <span class="arg">btw</span>,         <span class="c">/* [IN] Number of bytes to write */</span>
22e6865dcdSopenharmony_ci  UINT* <span class="arg">bw</span>          <span class="c">/* [OUT] Pointer to the variable to return number of bytes written */</span>
23e6865dcdSopenharmony_ci);
24e6865dcdSopenharmony_ci</pre>
25e6865dcdSopenharmony_ci</div>
26e6865dcdSopenharmony_ci
27e6865dcdSopenharmony_ci<div class="para arg">
28e6865dcdSopenharmony_ci<h4>Parameters</h4>
29e6865dcdSopenharmony_ci<dl class="par">
30e6865dcdSopenharmony_ci<dt>fp</dt>
31e6865dcdSopenharmony_ci<dd>Pointer to the open file object structure.</dd>
32e6865dcdSopenharmony_ci<dt>buff</dt>
33e6865dcdSopenharmony_ci<dd>Pointer to the data to be written.</dd>
34e6865dcdSopenharmony_ci<dt>btw</dt>
35e6865dcdSopenharmony_ci<dd>Specifies number of bytes to write in range of <tt>UINT</tt> type. If the data needs to be written fast, it should be written in large chunk as possible.</dd>
36e6865dcdSopenharmony_ci<dt>bw</dt>
37e6865dcdSopenharmony_ci<dd>Pointer to the <tt>UINT</tt> variable that receives the number of bytes written. This value is always valid after the function call regardless of the function return code. If the return value is equal to <tt class="arg">btw</tt>, the function return code should be <tt>FR_OK</tt>.</dd>
38e6865dcdSopenharmony_ci</dl>
39e6865dcdSopenharmony_ci</div>
40e6865dcdSopenharmony_ci
41e6865dcdSopenharmony_ci
42e6865dcdSopenharmony_ci<div class="para ret">
43e6865dcdSopenharmony_ci<h4>Return Values</h4>
44e6865dcdSopenharmony_ci<p>
45e6865dcdSopenharmony_ci<a href="rc.html#ok">FR_OK</a>,
46e6865dcdSopenharmony_ci<a href="rc.html#de">FR_DISK_ERR</a>,
47e6865dcdSopenharmony_ci<a href="rc.html#ie">FR_INT_ERR</a>,
48e6865dcdSopenharmony_ci<a href="rc.html#dn">FR_DENIED</a>,
49e6865dcdSopenharmony_ci<a href="rc.html#io">FR_INVALID_OBJECT</a>,
50e6865dcdSopenharmony_ci<a href="rc.html#tm">FR_TIMEOUT</a>
51e6865dcdSopenharmony_ci</p>
52e6865dcdSopenharmony_ci</div>
53e6865dcdSopenharmony_ci
54e6865dcdSopenharmony_ci
55e6865dcdSopenharmony_ci<div class="para desc">
56e6865dcdSopenharmony_ci<h4>Description</h4>
57e6865dcdSopenharmony_ci<p>The function starts to write data to the file at the file offset pointed by read/write pointer. The read/write pointer advances as number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> &lt; <tt class="arg">btw</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
58e6865dcdSopenharmony_ci</div>
59e6865dcdSopenharmony_ci
60e6865dcdSopenharmony_ci
61e6865dcdSopenharmony_ci<div class="para comp">
62e6865dcdSopenharmony_ci<h4>QuickInfo</h4>
63e6865dcdSopenharmony_ci<p>Available when <tt><a href="config.html#fs_readonly">FF_FS_READONLY</a> == 0</tt>.</p>
64e6865dcdSopenharmony_ci</div>
65e6865dcdSopenharmony_ci
66e6865dcdSopenharmony_ci
67e6865dcdSopenharmony_ci<div class="para use">
68e6865dcdSopenharmony_ci<h4>Example</h4>
69e6865dcdSopenharmony_ci<p>Refer to the example in <tt>f_open</tt>.</p>
70e6865dcdSopenharmony_ci</div>
71e6865dcdSopenharmony_ci
72e6865dcdSopenharmony_ci
73e6865dcdSopenharmony_ci<div class="para ref">
74e6865dcdSopenharmony_ci<h4>See Also</h4>
75e6865dcdSopenharmony_ci<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">fputc</a>, <a href="puts.html">fputs</a>, <a href="printf.html">fprintf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
76e6865dcdSopenharmony_ci</div>
77e6865dcdSopenharmony_ci
78e6865dcdSopenharmony_ci<p class="foot"><a href="../00index_e.html">Return</a></p>
79e6865dcdSopenharmony_ci</body>
80e6865dcdSopenharmony_ci</html>
81