version 1.32, 2005/06/02 20:19:30 |
version 1.33, 2005/06/14 03:56:14 |
|
|
int |
int |
cvs_remove_dir(const char *path) |
cvs_remove_dir(const char *path) |
{ |
{ |
|
int ret = -1; |
size_t len; |
size_t len; |
DIR *dirp; |
DIR *dirp; |
struct dirent *ent; |
struct dirent *ent; |
|
|
continue; |
continue; |
|
|
len = cvs_path_cat(path, ent->d_name, fpath, sizeof(fpath)); |
len = cvs_path_cat(path, ent->d_name, fpath, sizeof(fpath)); |
if (len >= sizeof(fpath)) { |
if (len >= sizeof(fpath)) |
closedir(dirp); |
goto done; |
return (-1); |
|
} |
|
|
|
if (ent->d_type == DT_DIR) { |
if (ent->d_type == DT_DIR) { |
if (cvs_remove_dir(fpath) == -1) { |
if (cvs_remove_dir(fpath) == -1) |
closedir(dirp); |
goto done; |
return (-1); |
|
} |
|
} else if ((unlink(fpath) == -1) && (errno != ENOENT)) { |
} else if ((unlink(fpath) == -1) && (errno != ENOENT)) { |
cvs_log(LP_ERRNO, "failed to remove '%s'", fpath); |
cvs_log(LP_ERRNO, "failed to remove '%s'", fpath); |
return (-1); |
goto done; |
} |
} |
} |
} |
|
|
closedir(dirp); |
|
|
|
if ((rmdir(path) == -1) && (errno != ENOENT)) { |
if ((rmdir(path) == -1) && (errno != ENOENT)) { |
cvs_log(LP_ERRNO, "failed to remove '%s'", path); |
cvs_log(LP_ERRNO, "failed to remove '%s'", path); |
return (-1); |
goto done; |
} |
} |
|
|
return (0); |
ret = 0; |
|
done: |
|
closedir(dirp); |
|
return (ret); |
} |
} |
|
|
/* |
/* |