From: David van Moolenbroek Date: Sun, 12 Jul 2009 14:44:37 +0000 (+0000) Subject: make remove(3) remove directories as well X-Git-Tag: v3.1.5~215 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=1d0e43c8f1fd0a5676396ad5c5407fa4e375cd0c;p=minix.git make remove(3) remove directories as well --- diff --git a/lib/stdio/remove.c b/lib/stdio/remove.c index 72c5780ea..7c985ba59 100755 --- a/lib/stdio/remove.c +++ b/lib/stdio/remove.c @@ -4,10 +4,24 @@ /* $Header$ */ #include +#include +int _rmdir(const char *path); int _unlink(const char *path); int remove(const char *filename) { - return _unlink(filename); + int saved_errno, retval; + + saved_errno = errno; + + retval = _rmdir(filename); + + if (retval == -1 && errno == ENOTDIR) { + errno = saved_errno; + + retval = _unlink(filename); + } + + return retval; }