1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

config: support libconfig include directories

This commit is contained in:
Steffen Vogel 2020-07-10 13:27:25 +02:00 committed by Steffen Vogel
parent d83076d869
commit 459759a037

View file

@ -28,6 +28,7 @@
#include <fstream>
#include <iostream>
#include <iomanip>
#include <filesystem>
#include <villas/utils.hpp>
#include <villas/log.hpp>
@ -36,6 +37,8 @@
#include <villas/node/exceptions.hpp>
#include <villas/config_helper.hpp>
namespace fs = std::filesystem;
using namespace villas;
using namespace villas::node;
@ -150,15 +153,15 @@ json_t * Config::libconfigDecode(FILE *f)
config_init(&cfg);
config_set_auto_convert(&cfg, 1);
/* Setup libconfig include path.
* This is only supported for local files */
// if (isLocalFile(uri)) {
// char *cpy = strdup(uri.c_str());
/* Setup libconfig include path. */
auto uri = fs::read_symlink(fs::path("/proc/self/fd") / std::to_string(fileno(f)));
if (isLocalFile(uri)) {
const auto &inclDir = uri.parent_path();
// config_set_include_dir(&cfg, dirname(cpy));
logger->info("Setting include dir to: {}", inclDir);
// free(cpy);
// }
config_set_include_dir(&cfg, inclDir.c_str());
}
/* Rewind before re-reading */
rewind(f);