File system
File system unlink
// PROTOTYPE
int unlink(const char* pathname)
Removes a file from the file system.
pathname: The pathname to the file (Unix-style, with forward slash as the directory separator).
Returns 0 on success. On error, returns -1 and sets errno. Some possible errno values include:
EEXISTorENOTEMPTY: Directory is not empty.
Note:
You must not call unlink() with an open directory handle to one or more parent directories! The common case where this can occur is if using the combination of opendir() and readdir(), and attempting to remove a file from within the loop. Doing so can cause an error, or, in some cases, corrupt the file system.
You should either save a list of all files to delete then unlink them after closedir, or use findLeafEntry(). For examples of the latter, see the SequentialFileRK library, or the rmrf helper in Device OS.