From 2079455eeced928179f7f7c16d4a8b87c936bc09 Mon Sep 17 00:00:00 2001 From: Joan Torres Date: Mon, 18 Dec 2023 12:36:49 +0100 Subject: [PATCH] [proxy,modules] allow compiling with old c++ compiler For dyn-channel-dump. On C++17 there's the filesystem standard library. Newer c++ compilers use it with . However, older c++ compilers use it with . --- .../dyn-channel-dump/dyn-channel-dump.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp b/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp index a56afe077..990281904 100644 --- a/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp +++ b/server/proxy/modules/dyn-channel-dump/dyn-channel-dump.cpp @@ -32,7 +32,15 @@ #include #include #include +#if __has_include() #include +namespace fs = std::filesystem; +#elif __has_include() +#include +namespace fs = std::experimental::filesystem; +#else +#error Could not find system header "" or "" +#endif #include #include @@ -122,15 +130,15 @@ class ChannelData bool ensure_path_exists() { - if (!std::filesystem::exists(_base)) + if (!fs::exists(_base)) { - if (!std::filesystem::create_directories(_base)) + if (!fs::create_directories(_base)) { WLog_ERR(TAG, "Failed to create dump directory %s", _base.c_str()); return false; } } - else if (!std::filesystem::is_directory(_base)) + else if (!fs::is_directory(_base)) { WLog_ERR(TAG, "dump path %s is not a directory", _base.c_str()); return false; @@ -158,7 +166,7 @@ class ChannelData } private: - std::filesystem::path filepath(const std::string& channel, bool back, uint64_t count) const + fs::path filepath(const std::string& channel, bool back, uint64_t count) const { auto name = idstr(channel, back); char cstr[32] = {}; @@ -181,7 +189,7 @@ class ChannelData } private: - std::filesystem::path _base; + fs::path _base; std::vector _channels_to_dump; std::mutex _mux;