diff --git a/src/path_util.c b/src/path_util.c index 719d690..c30c5ae 100644 --- a/src/path_util.c +++ b/src/path_util.c @@ -30,9 +30,8 @@ char *default_path(const char *biphome, const char *filename, const char *desc) void assert_path_exists(char *path) { - FILE* f; - if ((f = fopen(path, "r")) == NULL) - fatal("Unable to open file %s for reading", path); - else - fclose(f); + struct stat st_buf; + + if (stat(path, &st_buf) != 0) + fatal("Path %s doesn't exist (%s)", path, strerror(errno)); } diff --git a/src/path_util.h b/src/path_util.h index 87cbf6f..1e663c3 100644 --- a/src/path_util.h +++ b/src/path_util.h @@ -11,6 +11,9 @@ #ifndef PATH_UTIL_H #define PATH_UTIL_H +#include +#include + /* return path of filename located in bip home directory */ char *default_path(const char *biphome, const char *filename, const char *desc); /* exit program if path doesn't exist */