1
0
forked from bip/bip

Merge branch 'path_test_use_stat'

This commit is contained in:
Pierre-Louis Bonicoli 2018-03-22 02:37:38 +01:00
commit eaed46da14
Signed by untrusted user: pilou
GPG Key ID: ADC2651DDACD3538
2 changed files with 7 additions and 5 deletions

View File

@ -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));
}

View File

@ -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 */