blob: b56da06248f519de5b0a4327cca193e6b93c4f52 [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;
}