Versions Compared

Key

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

A new file can be created using FSFile_Open() or fs_fopen(), if opened in write or append mode. There are a few other ways that new files can be created (most of which also apply to new directories).

The simplest is the FSEntry_Create() function, which just makes a new file or directory:

If the second argument, entry_type, is FS_ENTRY_TYPE_DIR the new entry will be a directory. The third argument, excl, indicates whether the creation should be exclusive. If it is exclusive (excl is DEF_YES), nothing will happen if the file already exists. Otherwise, the file currently specified by the file name will be deleted and a new empty file with that name created.

Similar functions exist to copy and rename an entry:

FSEntry_Copy() can only be used to copy files. The first two arguments of each of these are both full paths; the second path is not relative to the parent directory of the first. As with FSEntry_Create(), the third argument of each, excl, indicates whether the creation should be exclusive. If it is exclusive (excl is DEF_YES), nothing will happen if the destination or new file already exists.