mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
remove dependency on std::filesystem
This commit is contained in:
parent
35e056dbb7
commit
2b21e5f7c6
5 changed files with 30 additions and 20 deletions
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit dd9304ca059efffe053b74159ca32b16a5eb4597
|
||||
Subproject commit 3e062fdc0f311d9eb4bc541b7a292def71f87cb0
|
|
@ -29,13 +29,10 @@
|
|||
|
||||
#include <functional>
|
||||
#include <regex>
|
||||
#include <filesystem>
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/log.hpp>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
|
@ -76,7 +73,7 @@ protected:
|
|||
json_t * walkStrings(json_t *in, str_walk_fcn_t cb);
|
||||
|
||||
/** Get the include dirs */
|
||||
std::list<fs::path> getIncludeDirs(FILE *f) const;
|
||||
std::list<std::string> getIncludeDirectories(FILE *f) const;
|
||||
|
||||
public:
|
||||
json_t *root;
|
||||
|
|
|
@ -40,10 +40,6 @@ if(UNIX AND NOT APPLE)
|
|||
list(APPEND LIBRARIES "rt")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||
list(APPEND LIBRARIES "-lstdc++fs")
|
||||
endif()
|
||||
|
||||
set(LIB_SRC
|
||||
config_helper.cpp
|
||||
config.cpp
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
#include <linux/limits.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
|
||||
|
@ -122,16 +123,34 @@ json_t * Config::decode(FILE *f)
|
|||
return root;
|
||||
}
|
||||
|
||||
std::list<fs::path> Config::getIncludeDirs(FILE *f) const
|
||||
std::list<std::string> Config::getIncludeDirectories(FILE *f) const
|
||||
{
|
||||
auto uri = fs::read_symlink(fs::path("/proc/self/fd") / std::to_string(fileno(f)));
|
||||
if (isLocalFile(uri)) {
|
||||
return {
|
||||
uri.parent_path()
|
||||
};
|
||||
int ret, fd;
|
||||
char buf[PATH_MAX];
|
||||
char *dir;
|
||||
|
||||
std::list<std::string> dirs;
|
||||
|
||||
dir = getcwd(buf, sizeof(buf));
|
||||
if (dir != nullptr)
|
||||
dirs.push_back(dir);
|
||||
|
||||
fd = fileno(f);
|
||||
if (fd < 0)
|
||||
throw SystemError("Failed to get file descriptor");
|
||||
|
||||
auto path = fmt::format("/proc/self/fd/{}", fd);
|
||||
|
||||
ret = readlink(path.c_str(), buf, sizeof(buf));
|
||||
if (ret > 0) {
|
||||
buf[ret] = 0;
|
||||
if (isLocalFile(buf)) {
|
||||
dir = dirname(buf);
|
||||
dirs.push_back(dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
return { };
|
||||
|
||||
return dirs;
|
||||
}
|
||||
|
||||
#ifdef WITH_CONFIG
|
||||
|
@ -145,7 +164,7 @@ json_t * Config::libconfigDecode(FILE *f)
|
|||
config_set_auto_convert(&cfg, 1);
|
||||
|
||||
/* Setup libconfig include path. */
|
||||
auto inclDirs = getIncludeDirs(f);
|
||||
auto inclDirs = getIncludeDirectories(f);
|
||||
if (inclDirs.size() > 0) {
|
||||
logger->info("Setting include dir to: {}", inclDirs.front());
|
||||
|
||||
|
|
|
@ -22,13 +22,11 @@
|
|||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <criterion/criterion.h>
|
||||
|
||||
#include <villas/utils.hpp>
|
||||
#include <villas/config.hpp>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
using namespace villas::node;
|
||||
|
||||
// cppcheck-suppress syntaxError
|
||||
|
|
Loading…
Add table
Reference in a new issue