summaryrefslogtreecommitdiff
path: root/fatfs/documents/doc/open.html
diff options
context:
space:
mode:
Diffstat (limited to 'fatfs/documents/doc/open.html')
-rw-r--r--fatfs/documents/doc/open.html34
1 files changed, 17 insertions, 17 deletions
diff --git a/fatfs/documents/doc/open.html b/fatfs/documents/doc/open.html
index c00c5e4..cc8b87a 100644
--- a/fatfs/documents/doc/open.html
+++ b/fatfs/documents/doc/open.html
@@ -34,15 +34,15 @@ FRESULT f_open (
<dd>Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.<br>
<table class="lst">
<tr><th>Flags</th><th>Meaning</th></tr>
-<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.</tr>
-<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file. Combine with <tt>FA_READ</tt> for read-write access.</td></tr>
-<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr>
+<tr><td>FA_READ</td><td>Specifies read access to the file. Data can be read from the file.</tr>
+<tr><td>FA_WRITE</td><td>Specifies write access to the file. Data can be written to the file. Combine with <tt>FA_READ</tt> for read-write access.</td></tr>
+<tr><td>FA_OPEN_EXISTING</td><td>Opens a file. The function fails if the file is not existing. (Default)</td></tr>
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it will be truncated and overwritten.</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file will be created.</td></tr>
<tr><td>FA_OPEN_APPEND</td><td>Same as <tt>FA_OPEN_ALWAYS</tt> except the read/write pointer is set end of the file.</td></tr>
</table>
-Mode flags of POSIX fopen() corresponds to FatFs mode flags as follows:<br>
+Mode flags in POSIX fopen() function corresponds to FatFs mode flags as follows:<br>
<table class="lst2">
<tr><th>POSIX</th><th>FatFs</th></tr>
<tr><td>"r"</td><td>FA_READ</td></tr>
@@ -86,7 +86,7 @@ Mode flags of POSIX fopen() corresponds to FatFs mode flags as follows:<br>
<div class="para desc">
<h4>Description</h4>
-<p>The <tt>f_open</tt> function opens a file and creates a <em>file object</em>. The file object is used for subsequent read/write operations to the file to identify the file. Open file should be closed with <a href="close.html"><tt>f_close</tt></a> function after the session of the file access. If any change to the file is made and not closed prior to power down, media removal or re-mount, or the file can be collapsed.</p>
+<p>The <tt>f_open</tt> function opens a file and creates a <em>file object</em>. The file object is an identifier for subsequent operations to the file. Open file should be closed with <a href="close.html"><tt>f_close</tt></a> function after the session of the file access. If any change to the file has been made and not closed prior to power off, media removal or re-mount, or the file can be collapsed.</p>
<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with any write mode flag is always prohibited.</p>
</div>
@@ -111,14 +111,14 @@ int main (void)
FRESULT fr; <span class="c">/* FatFs return code */</span>
- <span class="c">/* Register work area to the default drive */</span>
+ <span class="c">/* Give a work area to the default drive */</span>
f_mount(&amp;FatFs, "", 0);
<span class="c">/* Open a text file */</span>
fr = <em>f_open</em>(&amp;fil, "message.txt", FA_READ);
if (fr) return (int)fr;
- <span class="c">/* Read all lines and display it */</span>
+ <span class="c">/* Read every line and display it */</span>
while (f_gets(line, sizeof line, &amp;fil)) {
printf(line);
}
@@ -134,16 +134,16 @@ int main (void)
int main (void)
{
- FATFS fs[2]; <span class="c">/* Work area (filesystem object) for logical drives */</span>
+ FATFS fs0, fs1; <span class="c">/* Work area (filesystem object) for logical drives */</span>
FIL fsrc, fdst; <span class="c">/* File objects */</span>
BYTE buffer[4096]; <span class="c">/* File copy buffer */</span>
FRESULT fr; <span class="c">/* FatFs function common result code */</span>
UINT br, bw; <span class="c">/* File read/write count */</span>
- <span class="c">/* Register work area for each logical drive */</span>
- f_mount(&amp;fs[0], "0:", 0);
- f_mount(&amp;fs[1], "1:", 0);
+ <span class="c">/* Give work areas to each logical drive */</span>
+ f_mount(&amp;fs0, "0:", 0);
+ f_mount(&amp;fs1, "1:", 0);
<span class="c">/* Open source file on the drive 1 */</span>
fr = <em>f_open</em>(&amp;fsrc, "1:file.bin", FA_READ);
@@ -155,10 +155,10 @@ int main (void)
<span class="c">/* Copy source to destination */</span>
for (;;) {
- fr = f_read(&amp;fsrc, buffer, sizeof buffer, &amp;br); <span class="c">/* Read a chunk of source file */</span>
- if (fr || br == 0) break; <span class="c">/* error or eof */</span>
- fr = f_write(&amp;fdst, buffer, br, &amp;bw); <span class="c">/* Write it to the destination file */</span>
- if (fr || bw &lt; br) break; <span class="c">/* error or disk full */</span>
+ fr = f_read(&amp;fsrc, buffer, sizeof buffer, &amp;br); <span class="c">/* Read a chunk of data from the source file */</span>
+ if (br == 0) break; <span class="c">/* error or eof */</span>
+ fr = f_write(&amp;fdst, buffer, br, &amp;bw); <span class="c">/* Write it to the destination file */</span>
+ if (bw &lt; br) break; <span class="c">/* error or disk full */</span>
}
<span class="c">/* Close open files */</span>
@@ -166,8 +166,8 @@ int main (void)
f_close(&amp;fdst);
<span class="c">/* Unregister work area prior to discard it */</span>
- f_mount(NULL, "0:", 0);
- f_mount(NULL, "1:", 0);
+ f_unmount("0:");
+ f_unmount("1:");
return (int)fr;
}