Creating New Files and Directories
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:
FSEntry_Create("\\file.txt", /* file name */
FS_ENTRY_TYPE_FILE, /* means entry will be a file */
DEF_NO, /* DEF_NO means creation NOT exclusive */
&err); /* return error */
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("\\dir\\src.txt", /* source file name */
"\\dir\\dest.txt », /* destination file name */
DEF_NO, /* DEF_NO means creation not exclusive */
&err); /* return error */
FSEntry_Rename ("\\dir\\oldname.txt", /* old file name */
"\\dir\\newname.txt", /* new file name */
DEF_NO, /* DEF_NO means creation not exclusive */
&err); /* return error */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
.