From be038f9cb2d4302d74c0edadd9abf2b282adc7c3 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 18 Jan 2012 21:43:00 -0600 Subject: 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 --- lib/libalpm/util.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'lib/libalpm/util.c') 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 -- cgit v1.2.3-24-g4f1b