diff --git a/lib/api/server.cpp b/lib/api/server.cpp index 0b4788b83..bbf580457 100644 --- a/lib/api/server.cpp +++ b/lib/api/server.cpp @@ -27,7 +27,12 @@ #include #include -#include + +#if __GNUC__ <= 7 + #include +#else + #include +#endif #include #include @@ -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);