From 730e03e60740905f3c97bed11db637e3dff2801a Mon Sep 17 00:00:00 2001 From: Oskar Date: Tue, 16 Jul 2024 18:09:08 +0200 Subject: function to check if it has been long enough --- trashsys.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/trashsys.c b/trashsys.c index 4e960c0..5450fd1 100644 --- a/trashsys.c +++ b/trashsys.c @@ -787,6 +787,26 @@ int clear_all_files (char *paths, const int mode) { return FUNCTION_SUCCESS; } +int compare_unixtime (time_t deleted_time, int difference_in_days) { + + time_t diff_converted; + time_t current_time; + time_t final; + diff_converted = (time_t)difference_in_days * 86400; + current_time = time(NULL); + if(current_time == -1) { + return FUNCTION_FAILURE; + } + + final = current_time - deleted_time; + if(final < diff_converted) { + printf("failure\n"); + return FUNCTION_FAILURE; + } + printf("success\n"); + return FUNCTION_SUCCESS; +} + int main (int argc, char *argv[]) { if (argc == 1) { -- cgit v1.2.3