Filesystem has eraseDir() and eraseFile() methods. It should be possible to use erase() that works on both directories and files.