diff --git a/include/lib/util_path.h b/include/lib/util_path.h index 33525469..c4085af9 100644 --- a/include/lib/util_path.h +++ b/include/lib/util_path.h @@ -20,5 +20,6 @@ bool util_path_is_readable(const char *fmt, ...); bool util_path_is_writable(const char *fmt, ...); bool util_path_is_dir(const char *fmt, ...); bool util_path_is_reg_file(const char *fmt, ...); +bool util_path_exists(const char *fmt, ...); #endif /** LIB_UTIL_PATH_H @} */ diff --git a/libutil/util_path.c b/libutil/util_path.c index 9ee65fd2..7cf446ea 100644 --- a/libutil/util_path.c +++ b/libutil/util_path.c @@ -194,3 +194,15 @@ free_str: free(path); return rc; } + +bool util_path_exists(const char *fmt, ...) +{ + va_list ap; + char *path; + bool rc; + + UTIL_VASPRINTF(&path, fmt, ap); + rc = access(path, F_OK) == 0; + free(path); + return rc; +}