checking path: use stat
fopen was used because it's stdlib but stat is already used in other parts
This commit is contained in:
parent
385be75f7e
commit
3afb16d795
@ -29,9 +29,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));
|
||||
}
|
||||
|
@ -11,6 +11,9 @@
|
||||
#ifndef PATH_UTIL_H
|
||||
#define PATH_UTIL_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* 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 */
|
||||
|
Loading…
Reference in New Issue
Block a user