int cfs_delete_dir(const char *path) { int result = 1; struct chirp_dir *dir; struct chirp_dirent *d; if(cfs->unlink(path) == 0) /* Handle files and symlinks here */ return 0; dir = cfs->opendir(path); if(!dir) { return errno == ENOENT; } while((d = cfs->readdir(dir))) { char subdir[PATH_MAX]; if(!strcmp(d->name, ".")) continue; if(!strcmp(d->name, "..")) continue; sprintf(subdir, "%s/%s", path, d->name); if(!cfs_delete_dir(subdir)) { result = 0; } } cfs->closedir(dir); return cfs->rmdir(path) == 0 ? result : 0; }
static INT64_T chirp_fs_local_rmall(const char *path) { return cfs_delete_dir(path); }