return pakfire_path_join(cache_path, path);
}
-
-static int pakfire_cache_stat(PakfireCache cache, const char* filename, struct stat* buf) {
- char* cache_filename = pakfire_cache_get_full_path(cache, filename);
-
- int r = stat(cache_filename, buf);
- pakfire_free(cache_filename);
-
- return r;
-}
-
-PAKFIRE_EXPORT int pakfire_cache_has_file(PakfireCache cache, const char* filename) {
- struct stat buf;
- int r = pakfire_cache_stat(cache, filename, &buf);
-
- // Just check if stat() was sucessful.
- return (r == 0);
-}
const char* pakfire_cache_get_path(PakfireCache cache);
char* pakfire_cache_get_full_path(PakfireCache cache, const char* path);
-int pakfire_cache_has_file(PakfireCache cache, const char* filename);
-
#ifdef PAKFIRE_PRIVATE
struct _PakfireCache {
void pakfire_set_cache_path(Pakfire pakfire, const char* path);
int pakfire_cache_destroy(Pakfire pakfire, const char* path);
+int pakfire_cache_access(Pakfire pakfire, const char* path, int mode);
int pakfire_cache_stat(Pakfire pakfire, const char* path, struct stat* buffer);
time_t pakfire_cache_age(Pakfire pakfire, const char* path);
FILE* pakfire_cache_open(Pakfire pakfire, const char* path, const char* flags);
return r;
}
+PAKFIRE_EXPORT int pakfire_cache_access(Pakfire pakfire, const char* path, int mode) {
+ char* cache_path = pakfire_get_cache_path(pakfire, path);
+
+ int r = pakfire_access(cache_path, NULL, mode);
+ pakfire_free(cache_path);
+
+ return r;
+}
+
PAKFIRE_EXPORT time_t pakfire_cache_age(Pakfire pakfire, const char* path) {
struct stat buffer;
#include <ftw.h>
#include <stdio.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <pakfire/cache.h>
#include <pakfire/constants.h>
char* cache_filename = pakfire_repocache_get_cache_path(repo_cache, filename);
PakfireCache cache = pakfire_repocache_cache(repo_cache);
- int r = pakfire_cache_has_file(cache, cache_filename);
+ int r = pakfire_cache_access(cache, cache_filename, R_OK);
pakfire_free(cache_filename);
return r;