Versions Compared

Key

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

...

The return value of this function should always be verified as non-NULL before the application proceeds to access the file. The first argument of this function is the path of the file; if working directories are disabled, this must be the absolute file path, beginning with either a volume name or a ‘\’ (see section 4-3 “μCµC/FS File and Directory Names and Paths”Paths). The second argument of this function is a string indicating the mode of the file; this must be one of the strings shown in the table below. Note that in all instances, the ‘b’ (binary) option has no affect on the behavior of file accesses.

fs_fopen() Mode String

Read?

Write?

Truncate?

Create?

Append?

“r” or “rb”

Yes

No

No

No

No

“w” or “wb”

No

Yes

Yes

Yes

No

“a” or “ab”

No

Yes

No

Yes

Yes

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

Yes

Yes

No

No

No

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

Yes

Yes

Yes

Yes

No

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

Yes

Yes

No

Yes

Yes

Table 10-2 fs_fopen() mode strings interpretations

After a file is opened, any of the file access functions valid for that its mode can be called. The most commonly used functions are fs_fread() and fs_fwrite(), which read or write a certain number of ‘items’ from a file:

...