summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-01-18 21:43:00 -0600
committerDan McGee <dan@archlinux.org>2012-01-23 12:21:11 -0600
commitbe038f9cb2d4302d74c0edadd9abf2b282adc7c3 (patch)
tree675ffc363d23d1ebb5520db69a2127172e647a2a /lib/libalpm/util.c
parentac239c54d0b8f83ee8a0a94456fc84da7f583ccb (diff)
downloadpacman-be038f9cb2d4302d74c0edadd9abf2b282adc7c3.tar.xz
Remove rmrf implementation from backend
This moves the code for removal of local database entries right into be_local.c, which was the last user of the rmrf() function we had in our utility source file. We can simplify the implementation and make it non-recursive as we know the structure of the local database entries. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r--lib/libalpm/util.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 3cc4bbf7..24bf1fc0 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -397,52 +397,6 @@ cleanup:
return ret;
}
-/** Recursively removes a path similar to 'rm -rf'.
- * @param path path to remove
- * @return 0 on success, number of paths that could not be removed on error
- */
-int _alpm_rmrf(const char *path)
-{
- int errflag = 0;
- struct dirent *dp;
- DIR *dirp;
- struct stat st;
-
- if(_alpm_lstat(path, &st) == 0) {
- if(!S_ISDIR(st.st_mode)) {
- if(!unlink(path)) {
- return 0;
- } else {
- if(errno == ENOENT) {
- return 0;
- } else {
- return 1;
- }
- }
- } else {
- dirp = opendir(path);
- if(!dirp) {
- return 1;
- }
- for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
- if(dp->d_name) {
- if(strcmp(dp->d_name, "..") != 0 && strcmp(dp->d_name, ".") != 0) {
- char name[PATH_MAX];
- sprintf(name, "%s/%s", path, dp->d_name);
- errflag += _alpm_rmrf(name);
- }
- }
- }
- closedir(dirp);
- if(rmdir(path)) {
- errflag++;
- }
- }
- return errflag;
- }
- return 0;
-}
-
/** Determine if there are files in a directory.
* @param handle the context handle
* @param path the full absolute directory path