From 1e37dad1fc37f7626fa0c83441940bab673ef4c5 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Tue, 30 Jan 2018 09:27:08 -0800 Subject: Add helper to get mtime of file --- util.c | 10 ++++++++++ util.h | 1 + 2 files changed, 11 insertions(+) diff --git a/util.c b/util.c index 6d79f5d..d1858e0 100644 --- a/util.c +++ b/util.c @@ -125,6 +125,16 @@ int util_getUnixDatetime () { return tv.tv_sec; } +/** + * Get the last modified datetime + * of the file at path + */ +time_t util_getMTime (char *path) { + struct stat st; + if (stat(path, &st) != 0) return -1; + else return st.st_mtime; +} + /** * Convenience function to get current time as uint64_t. * diff --git a/util.h b/util.h index a706588..12cf5eb 100644 --- a/util.h +++ b/util.h @@ -35,6 +35,7 @@ void delayMilli (unsigned long millisecs); long getTimeMicrosecs (); uint64_t GetCurrentTimestamp (void); +time_t util_getMTime (char *path); int util_getUnixDatetime (); le_result_t util_flattenRes (le_result_t *res, int nRes); -- cgit v1.2.3