Only remove directories when removing recursively.

This commit is contained in:
Matt Kraai 2000-09-20 23:10:21 +00:00
parent cff3fe3ae9
commit 7c22b77162
2 changed files with 10 additions and 0 deletions

View File

@ -45,6 +45,11 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
perror(fileName);
return (FALSE);
}
if (rmdir(fileName) < 0) {
perror(fileName);
return (FALSE);

5
rm.c
View File

@ -45,6 +45,11 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
perror(fileName);
return (FALSE);
}
if (rmdir(fileName) < 0) {
perror(fileName);
return (FALSE);