Merge branch 'path_test_use_stat'
This commit is contained in:
commit
eaed46da14
@ -30,9 +30,8 @@ char *default_path(const char *biphome, const char *filename, const char *desc)
|
|||||||
|
|
||||||
void assert_path_exists(char *path)
|
void assert_path_exists(char *path)
|
||||||
{
|
{
|
||||||
FILE* f;
|
struct stat st_buf;
|
||||||
if ((f = fopen(path, "r")) == NULL)
|
|
||||||
fatal("Unable to open file %s for reading", path);
|
if (stat(path, &st_buf) != 0)
|
||||||
else
|
fatal("Path %s doesn't exist (%s)", path, strerror(errno));
|
||||||
fclose(f);
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
#ifndef PATH_UTIL_H
|
#ifndef PATH_UTIL_H
|
||||||
#define PATH_UTIL_H
|
#define PATH_UTIL_H
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
/* return path of filename located in bip home directory */
|
/* return path of filename located in bip home directory */
|
||||||
char *default_path(const char *biphome, const char *filename, const char *desc);
|
char *default_path(const char *biphome, const char *filename, const char *desc);
|
||||||
/* exit program if path doesn't exist */
|
/* exit program if path doesn't exist */
|
||||||
|
Loading…
Reference in New Issue
Block a user