2016-07-05 09:18:07 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the bip project
|
|
|
|
* Copyright (C) 2016 Pierre-Louis Bonicoli
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
* See the file "COPYING" for the exact licensing terms.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "path_util.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
char *default_path(const char *biphome, const char *filename, const char *desc)
|
|
|
|
{
|
|
|
|
char *conf_file;
|
2018-03-21 11:07:56 +01:00
|
|
|
// '/' and \0
|
2016-07-05 09:18:07 +02:00
|
|
|
conf_file = bip_malloc(strlen(biphome) + strlen(filename) + 2);
|
|
|
|
strcpy(conf_file, biphome);
|
|
|
|
conf_file[strlen(biphome)] = '/';
|
2018-03-21 11:07:56 +01:00
|
|
|
conf_file[strlen(biphome) + 1] = '\0';
|
2016-07-05 09:18:07 +02:00
|
|
|
strcat(conf_file, filename);
|
2018-03-21 11:32:46 +01:00
|
|
|
mylog(LOG_INFO, "Default %s: %s", desc, conf_file);
|
2016-07-05 09:18:07 +02:00
|
|
|
return conf_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
void assert_path_exists(char *path)
|
|
|
|
{
|
2018-03-21 11:54:20 +01:00
|
|
|
struct stat st_buf;
|
|
|
|
|
|
|
|
if (stat(path, &st_buf) != 0)
|
|
|
|
fatal("Path %s doesn't exist (%s)", path, strerror(errno));
|
2016-07-05 09:18:07 +02:00
|
|
|
}
|