From 991b3ff7e63314ea14a40bb437e49ec8553abff2 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 3 Jun 2011 16:42:41 -0500 Subject: Add helper methods for setting directory options This keeps duplicate code to a minimum. This will come in more handy as we refactor some of these option setters away. Signed-off-by: Dan McGee --- lib/libalpm/util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 5821bf9f..6f0763d5 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -56,6 +56,7 @@ #include "alpm.h" #include "alpm_list.h" #include "handle.h" +#include "trans.h" #ifndef HAVE_STRSEP /* This is a replacement for strsep which is not portable (missing on Solaris). @@ -606,15 +607,18 @@ const char *_alpm_filecache_setup(void) } else if(S_ISDIR(buf.st_mode) && (buf.st_mode & S_IWUSR)) { _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", cachedir); return cachedir; + } else { + _alpm_log(PM_LOG_DEBUG, "skipping cachedir: %s\n", cachedir); } } /* we didn't find a valid cache directory. use /tmp. */ - tmp = alpm_list_add(NULL, strdup("/tmp/")); + tmp = alpm_list_add(NULL, "/tmp/"); alpm_option_set_cachedirs(tmp); - _alpm_log(PM_LOG_DEBUG, "using cachedir: %s", "/tmp/\n"); + alpm_list_free(tmp); + _alpm_log(PM_LOG_DEBUG, "using cachedir: %s\n", "/tmp/"); _alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n")); - return alpm_list_getdata(tmp); + return "/tmp/"; } /** lstat wrapper that treats /path/dirsymlink/ the same as /path/dirsymlink. -- cgit v1.2.3-24-g4f1b