#define PAKFIRE_PATH_H
#include <stddef.h>
+#include <time.h>
#define pakfire_path_normalize(path) \
__pakfire_path_normalize(path, sizeof(path))
int pakfire_path_exists(const char* path);
+time_t pakfire_path_age(const char* path);
+
#endif /* PAKFIRE_PATH_H */
return n;
}
-time_t pakfire_path_age(const char* path);
-
int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len);
#define pakfire_hexlify(digest) __pakfire_hexlify(digest, sizeof(digest))
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
#include <unistd.h>
#include <pakfire/path.h>
int pakfire_path_exists(const char* path) {
return !access(path, F_OK);
}
+
+time_t pakfire_path_age(const char* path) {
+ struct stat st;
+
+ int r = stat(path, &st);
+ if (r < 0)
+ return -errno;
+
+ // Get current timestamp
+ time_t now = time(NULL);
+
+ // Return the difference since the file has been created and now
+ return now - st.st_ctime;
+}
return NULL;
}
-time_t pakfire_path_age(const char* path) {
- struct stat st;
-
- int r = stat(path, &st);
- if (r == 0) {
- // Get current timestamp
- time_t now = time(NULL);
-
- // Return the difference since the file has been created and now
- return now - st.st_ctime;
- }
-
- return -1;
-}
-
int pakfire_file_write(struct pakfire* pakfire, const char* path,
uid_t owner, gid_t group, mode_t mode, const char* format, ...) {
va_list args;