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

fix compiler errors about non-existing std::filesystem namespace with GCC 7

This commit is contained in:
Steffen Vogel 2019-01-21 17:11:42 +01:00
parent df42a2880c
commit 9db4c8d2d2

View file

@ -27,7 +27,12 @@
#include <exception>
#include <algorithm>
#include <filesystem>
#if __GNUC__ <= 7
#include <experimental/filesystem>
#else
#include <filesystem>
#endif
#include <villas/config.h>
#include <villas/exceptions.hpp>
@ -39,6 +44,12 @@
using namespace villas;
using namespace villas::node::api;
#if __GNUC__ <= 7
namespace fs = std::experimental::filesystem;
#else
namespace fs = std::filesystem;
#endif
Server::Server(Api *a) :
state(STATE_INITIALIZED),
api(a)
@ -70,17 +81,17 @@ void Server::start()
struct sockaddr_un sun = { .sun_family = AF_UNIX };
std::filesystem::path socketPath = PREFIX "/var/lib/villas";
if (!std::filesystem::exists(socketPath)) {
fs::path socketPath = PREFIX "/var/lib/villas";
if (!fs::exists(socketPath)) {
logging.get("api")->info("Creating directory for API socket: {}", socketPath);
std::filesystem::create_directories(socketPath);
fs::create_directories(socketPath);
}
socketPath += "/node-" + api->getSuperNode()->getName() + ".sock";
if (std::filesystem::exists(socketPath)) {
if (fs::exists(socketPath)) {
logging.get("api")->info("Removing existing socket: {}", socketPath);
std::filesystem::remove(socketPath);
fs::remove(socketPath);
}
strncpy(sun.sun_path, socketPath.c_str(), sizeof(sun.sun_path) - 1);