fatfs v0.07e Nov 03,2009:
- Separated out configuration options from ff.h to ffconf.h. - Added a configuration option, _LFN_UNICODE. - Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH. - Fixed name matching error on the 13 char boundary. - Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
This commit is contained in:
1 parent
25f499b847
commit
e6cd91ca0b
76 files changed
+918
-636
No files matched your search
+24
-19
@@ -26,7 +26,7 @@ FRESULT f_open (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>FileObject</dt>
|
||||
<dd>Pointer to the file object structure to be created. After the f_open funciton succeeded, the file can be accessed with the file object structure until it is closed.</dd>
|
||||
<dd>Pointer to the file object structure to be created.</dd>
|
||||
<dt>FileName</dt>
|
||||
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to create or open.</dd>
|
||||
<dt>ModeFlags</dt>
|
||||
@@ -36,7 +36,7 @@ FRESULT f_open (
|
||||
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with FA_WRITE for read-write access.</td></tr>
|
||||
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with FA_READ 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_OPEN_ALWAYS</td><td>Opens the file, if it is existing. If not, the function creates the new file.</td></tr>
|
||||
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file, if it is existing. If not, a new file is created.</td></tr>
|
||||
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails if the file is already existing.</td></tr>
|
||||
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr>
|
||||
</table>
|
||||
@@ -76,16 +76,21 @@ FRESULT f_open (
|
||||
<dt>FR_NOT_ENABLED</dt>
|
||||
<dd>The logical drive has no work area.</dd>
|
||||
<dt>FR_NO_FILESYSTEM</dt>
|
||||
<dd>There is no valid FAT partition on the disk.</dd>
|
||||
<dd>There is no valid FAT volume on the disk.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The created file object is used for subsequent calls to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file may be collapsed.</p>
|
||||
<p>A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file may be collapsed.</p>
|
||||
<p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p>
|
||||
<p>The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not available in read-only configuration.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -94,38 +99,38 @@ FRESULT f_open (
|
||||
<pre>
|
||||
void main (void)
|
||||
{
|
||||
FATFS fs[2]; // Work area (file system object) for logical drives
|
||||
FIL fsrc, fdst; // file objects
|
||||
BYTE buffer[4096]; // file copy buffer
|
||||
FRESULT res; // FatFs function common result code
|
||||
UINT br, bw; // File R/W count
|
||||
FATFS fs[2]; /* Work area (file system object) for logical drives */
|
||||
FIL fsrc, fdst; /* file objects */
|
||||
BYTE buffer[4096]; /* file copy buffer */
|
||||
FRESULT res; /* FatFs function common result code */
|
||||
UINT br, bw; /* File R/W count */
|
||||
|
||||
|
||||
// Register work area for logical drives
|
||||
/* Register work area for logical drives */
|
||||
f_mount(0, &fs[0]);
|
||||
f_mount(1, &fs[1]);
|
||||
|
||||
// Open source file on the drive 1
|
||||
/* Open source file on the drive 1 */
|
||||
res = f_open(&fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
|
||||
if (res) die(res);
|
||||
|
||||
// Create destination file on the drive 0
|
||||
/* Create destination file on the drive 0 */
|
||||
res = f_open(&fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (res) die(res);
|
||||
|
||||
// Copy source to destination
|
||||
/* Copy source to destination */
|
||||
for (;;) {
|
||||
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
|
||||
if (res || br == 0) break; // error or eof
|
||||
if (res || br == 0) break; /* error or eof */
|
||||
res = f_write(&fdst, buffer, br, &bw);
|
||||
if (res || bw < br) break; // error or disk full
|
||||
if (res || bw < br) break; /* error or disk full */
|
||||
}
|
||||
|
||||
// Close all files
|
||||
/* Close open files */
|
||||
f_close(&fsrc);
|
||||
f_close(&fdst);
|
||||
|
||||
// Unregister work area before discard it
|
||||
/* Unregister work area prior to discard it */
|
||||
f_mount(0, NULL);
|
||||
f_mount(1, NULL);
|
||||
}
|
||||
@@ -134,7 +139,7 @@ void main (void)
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>References</h4>
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user