From 5630b9308323c3f3aaa09be8fe0f3aecaa826473 Mon Sep 17 00:00:00 2001 From: Leo C. Date: Sun, 30 Jun 2024 09:37:28 +0200 Subject: Import fatfs R0.15 --- fatfs/documents/doc/open.html | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'fatfs/documents/doc/open.html') 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 (
Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.
- - - + + +
FlagsMeaning
FA_READSpecifies read access to the object. Data can be read from the file.
FA_WRITESpecifies write access to the object. Data can be written to the file. Combine with FA_READ for read-write access.
FA_OPEN_EXISTINGOpens the file. The function fails if the file is not existing. (Default)
FA_READSpecifies read access to the file. Data can be read from the file.
FA_WRITESpecifies write access to the file. Data can be written to the file. Combine with FA_READ for read-write access.
FA_OPEN_EXISTINGOpens a file. The function fails if the file is not existing. (Default)
FA_CREATE_NEWCreates a new file. The function fails with FR_EXIST if the file is existing.
FA_CREATE_ALWAYSCreates a new file. If the file is existing, it will be truncated and overwritten.
FA_OPEN_ALWAYSOpens the file if it is existing. If not, a new file will be created.
FA_OPEN_APPENDSame as FA_OPEN_ALWAYS except the read/write pointer is set end of the file.
-Mode flags of POSIX fopen() corresponds to FatFs mode flags as follows:
+Mode flags in POSIX fopen() function corresponds to FatFs mode flags as follows:
@@ -86,7 +86,7 @@ Mode flags of POSIX fopen() corresponds to FatFs mode flags as follows:

Description

-

The f_open function opens a file and creates a file object. The file object is used for subsequent read/write operations to the file to identify the file. Open file should be closed with f_close 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.

+

The f_open function opens a file and creates a file object. The file object is an identifier for subsequent operations to the file. Open file should be closed with f_close 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.

If duplicated file open is needed, read here carefully. However duplicated open of a file with any write mode flag is always prohibited.

@@ -111,14 +111,14 @@ int main (void) FRESULT fr; /* FatFs return code */ - /* Register work area to the default drive */ + /* Give a work area to the default drive */ f_mount(&FatFs, "", 0); /* Open a text file */ fr = f_open(&fil, "message.txt", FA_READ); if (fr) return (int)fr; - /* Read all lines and display it */ + /* Read every line and display it */ while (f_gets(line, sizeof line, &fil)) { printf(line); } @@ -134,16 +134,16 @@ int main (void) int main (void) { - FATFS fs[2]; /* Work area (filesystem object) for logical drives */ + FATFS fs0, fs1; /* Work area (filesystem object) for logical drives */ FIL fsrc, fdst; /* File objects */ BYTE buffer[4096]; /* File copy buffer */ FRESULT fr; /* FatFs function common result code */ UINT br, bw; /* File read/write count */ - /* Register work area for each logical drive */ - f_mount(&fs[0], "0:", 0); - f_mount(&fs[1], "1:", 0); + /* Give work areas to each logical drive */ + f_mount(&fs0, "0:", 0); + f_mount(&fs1, "1:", 0); /* Open source file on the drive 1 */ fr = f_open(&fsrc, "1:file.bin", FA_READ); @@ -155,10 +155,10 @@ int main (void) /* Copy source to destination */ for (;;) { - fr = f_read(&fsrc, buffer, sizeof buffer, &br); /* Read a chunk of source file */ - if (fr || br == 0) break; /* error or eof */ - fr = f_write(&fdst, buffer, br, &bw); /* Write it to the destination file */ - if (fr || bw < br) break; /* error or disk full */ + fr = f_read(&fsrc, buffer, sizeof buffer, &br); /* Read a chunk of data from the source file */ + if (br == 0) break; /* error or eof */ + fr = f_write(&fdst, buffer, br, &bw); /* Write it to the destination file */ + if (bw < br) break; /* error or disk full */ } /* Close open files */ @@ -166,8 +166,8 @@ int main (void) f_close(&fdst); /* Unregister work area prior to discard it */ - f_mount(NULL, "0:", 0); - f_mount(NULL, "1:", 0); + f_unmount("0:"); + f_unmount("1:"); return (int)fr; } -- cgit v1.2.3
POSIXFatFs
"r"FA_READ