blob: db5f7d8f161dcf8e85c655aae15a7c1b7e6490c4 [file] [log] [blame] [raw]
#include <unistd.h>
#include <errno.h>
int remove(const char *file) {
/* First try to unlink since this is more frequently the necessary action. */
if(unlink(file) < 0
/* If it is indeed a directory... */
&& (errno != EISDIR
/* ...try to remove it. */
|| rmdir(file) < 0))
/* Cannot remove the object for whatever reason. */
return -1;
return 0;
}