Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
languagecpp
FS_FILE  *FSFile_Open (CPU_CHAR  *name_full,

...


                       FS_FLAGS   mode

...


                       FS_ERR    *p_err);


File

Called from

Code enabled by

fs_file.c

Application;

fs_fopen()

N/A

Open a file.

See fs_fopen() for  for more information.

Arguments

...

File access mode (see Notes #1 and #2).

p_err

Pointer to variable that will the receive return error code from this function:

...

Argument name_full passed a NULL pointer.

Or entry error (see Section B.04 µC/FS Error Codes).

Returned Value

None.

Notes/Warnings

  1. The access mode should be the logical OR of one or more flags :

    FS_FILE_ACCESS_MODE_RDFile opened for reads.
    FS_FILE_ACCESS_MODE_WRFile opened for writes.
    FS_FILE_ACCESS_MODE_CREATEFile will be created, if necessary.
    FS_FILE_ACCESS_MODE_TRUNCFile length will be truncated to 0.
    FS_FILE_ACCESS_MODE_APPENDAll writes will be performed at EOF.
    FS_FILE_ACCESS_MODE_EXCLFile will be opened if and only if it does not already exist.
    FS_FILE_ACCESS_MODE_CACHEDFile data will be cached.


  2. If FS_FILE_ACCESS_MODE_TRUNC is set, then FS_FILE_ACCESS_MODE_WR must also be set.
  3. If FS_FILE_ACCESS_MODE_EXCL is set, then FS_FILE_ACCESS_MODE_CREATE must also be set.
  4. FS_FILE_ACCESS_MODE_RD and/or FS_FILE_ACCESS_MODE_WR must be set.
  5. The mode string argument of fs_fopen() function can specify a subset of the possible valid modes for this function. The equivalent modes of fs_fopen() mode strings are shown in

...

  1. the table below.

    fopen() Mode String

    mode Equivalent

    “r” or “rb”

    FS_FILE_ACCESS_MODE_RD

    “w” or “wb”

    FS_FILE_ACCESS_MODE_WR |
    FS_FILE_ACCESS_MODE_CREATE |
    FS_FILE_ACCESS_MODE_TRUNC

    “a” or “ab”

    FS_FILE_ACCESS_MODE_WR |
    FS_FILE_ACCESS_MODE_CREATE |
    FS_FILE_ACCESS_MODE_APPEND

    “r+” or “rb+” or “r+b”

    FS_FILE_ACCESS_MODE_RD |
    FS_FILE_ACCESS_MODE_WR

    “w+” or “wb+” or “w+b”

    FS_FILE_ACCESS_MODE_RD |
    FS_FILE_ACCESS_MODE_WR |
    FS_FILE_ACCESS_MODE_CREATE |
    FS_FILE_ACCESS_MODE_TRUNC

    “a+” or “ab+” or “a+b”

    FS_FILE_ACCESS_MODE_RD |

    FS_FILE_ACCESS_MODE_WR |
    FS_FILE_ACCESS_MODE_CREATE |

    FS_FILE_ACCESS_MODE_APPEND

...