Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorAnatol Pomozov <anatol.pomozov@gmail.com>2020-04-23 17:28:43 -0700
committerAllan McRae <allan@archlinux.org>2020-07-07 21:36:56 +1000
commit78d6dcec6c49bd2fa830237a46fd14337bc9fd4c (patch)
tree8c27584c0cbbab779151b76aab7831974d1af2c9 /lib/libalpm/util.c
parent34ba8d984d89393ab85ca67724b87af67ff004c3 (diff)
Add a utility function to check whether a file exists in the cache
It is similar to _alpm_filecache_find() but does not return a dynamically allocated memory to user. Thus the user does not need to free this resource. Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r--lib/libalpm/util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index ead03004..76728eb4 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -834,6 +834,20 @@ char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename)
return NULL;
}
+/** Check whether a filename exists in a registered alpm cachedir.
+ * @param handle the context handle
+ * @param filename name of file to find
+ * @return 0 if the filename was not found, 1 otherwise
+ */
+int _alpm_filecache_exists(alpm_handle_t *handle, const char *filename)
+{
+ int res;
+ char *fpath = _alpm_filecache_find(handle, filename);
+ res = (fpath != NULL);
+ FREE(fpath);
+ return res;
+}
+
/** Check the alpm cachedirs for existence and find a writable one.
* If no valid cache directory can be found, use /tmp.
* @param handle the context handle