int find_binary(const char *name, char **filename) {
assert(name);
+ assert(filename);
+
if (strchr(name, '/')) {
char *p;
}
}
-bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update)
-{
- unsigned int i;
+bool paths_check_timestamp(char **paths, usec_t *timestamp, bool update) {
bool changed = false;
+ char **i;
+
+ assert(timestamp);
if (paths == NULL)
- goto out;
+ return false;
- for (i = 0; paths[i]; i++) {
+ STRV_FOREACH(i, paths) {
struct stat stats;
+ usec_t u;
- if (stat(paths[i], &stats) < 0)
+ if (stat(*i, &stats) < 0)
continue;
- if (paths_ts_usec[i] == timespec_load(&stats.st_mtim))
- continue;
+ u = timespec_load(&stats.st_mtim);
/* first check */
- if (paths_ts_usec[i] != 0) {
- log_debug("reload - timestamp of '%s' changed\n", paths[i]);
- changed = true;
- }
+ if (*timestamp >= u)
+ continue;
+
+ log_debug("timestamp of '%s' changed\n", *i);
/* update timestamp */
- if (update)
- paths_ts_usec[i] = timespec_load(&stats.st_mtim);
+ if (update) {
+ *timestamp = u;
+ changed = true;
+ } else
+ return true;
}
-out:
+
return changed;
}