int pakfire_format_speed(char* dst, size_t length, double value);
char* pakfire_format_date(time_t t);
+#define pakfire_strftime_now(dest, format) \
+ __pakfire_strftime_now(dest, sizeof(dest) - 1, format)
+int __pakfire_strftime_now(char* dest, size_t length, const char* format)
+ __attribute__((format(strftime, 3, 0)));;
+
int pakfire_path_exists(const char* path);
time_t pakfire_path_age(const char* path);
return pakfire_strftime("%Y-%m-%d", t);
}
+int __pakfire_strftime_now(char* dest, size_t length, const char* format) {
+ struct tm tm;
+
+ // Fetch the current time
+ const time_t t = time(NULL);
+ if (t < 0)
+ return 1;
+
+ // Convert to struct tm
+ struct tm* now = gmtime_r(&t, &tm);
+ if (!now)
+ return 1;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ strftime(dest, length, format, now);
+#pragma GCC diagnostic pop
+
+ return 0;
+}
+
int __pakfire_path_join(char* dest, size_t length,
const char* first, const char* second) {
if (!first)