version 1.16 | | version 1.17 |
---|
| | |
/* | | /* |
* static char *rcsid_porting_c = | | * static char *rcsid_porting_c = |
* "$Id: porting.c,v 1.16 2002/10/08 06:38:25 mwedel Exp $"; | | * "$Id: porting.c,v 1.17 2002/12/03 07:40:10 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
struct dirent *de; | | struct dirent *de; |
| | |
for (de=readdir(dirp); de; de = readdir(dirp)) { | | for (de=readdir(dirp); de; de = readdir(dirp)) { |
status=stat(de->d_name, &statbuf); | | /* Don't remove '.' or '..' In theory we should do a better |
/* Linus actually has a type field in the dirent structure, | | * check for .., but the directories we are removing are fairly |
| | * limited and should not have dot files in them. |
| | */ |
| | if (de->d_name[0] == '.') continue; |
| | |
| | /* Linux actually has a type field in the dirent structure, |
* but that is not portable - stat should be portable | | * but that is not portable - stat should be portable |
*/ | | */ |
| | status=stat(de->d_name, &statbuf); |
if ((status!=-1) && (S_ISDIR(statbuf.st_mode))) { | | if ((status!=-1) && (S_ISDIR(statbuf.st_mode))) { |
sprintf(buf,"%s/%s", path, de->d_name); | | sprintf(buf,"%s/%s", path, de->d_name); |
remove_directory(buf); | | remove_directory(buf); |
continue; | | continue; |
} | | } |
/* Don't remove '.' or '..' In theory we should do a better | | |
* check for .., but the directories we are removing are fairly | | |
* limited and should not have dot files in them. | | |
*/ | | |
if (de->d_name[0] == '.') continue; | | |
sprintf(buf,"%s/%s", path, de->d_name); | | sprintf(buf,"%s/%s", path, de->d_name); |
if (unlink(buf)) { | | if (unlink(buf)) { |
LOG(llevError,"Unable to remove directory %s\n", path); | | LOG(llevError,"Unable to remove directory %s\n", path); |
| | |
} | | } |
closedir(dirp); | | closedir(dirp); |
} | | } |
if (unlink(path)) { | | if (rmdir(path)) { |
LOG(llevError,"Unable to remove directory %s\n", path); | | LOG(llevError,"Unable to remove directory %s\n", path); |
} | | } |
} | | } |