1 2 3 4 5 6 7 8 9 10 11
#include <unistd.h> #include <errno.h> int remove(const char* filename) { if (unlink(filename)) { if (errno==EISDIR) return rmdir(filename); return -1; } return 0; }