AP_Filesystem: make unlink do both directories and files on posix

match FATFS behaviour
This commit is contained in:
Andrew Tridgell 2019-11-02 21:11:29 +11:00
parent 15fc3f3d75
commit 7c35d2d56a
1 changed files with 7 additions and 1 deletions

View File

@ -67,7 +67,13 @@ int AP_Filesystem::stat(const char *pathname, struct stat *stbuf)
int AP_Filesystem::unlink(const char *pathname)
{
return ::unlink(pathname);
// we match the FATFS interface and use unlink
// for both files and directories
int ret = ::rmdir(pathname);
if (ret == -1) {
ret = ::unlink(pathname);
}
return ret;
}
int AP_Filesystem::mkdir(const char *pathname)