From e8b9e32e12a86c95fc887e677ec5613a99358ef6 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Sat, 22 Jun 2019 20:21:42 +0300 Subject: [PATCH] Fix for using test data directories --- components/common/cpp/include/ftl/configuration.hpp | 2 ++ components/common/cpp/src/configuration.cpp | 5 +++++ components/rgbd-sources/src/source.cpp | 2 +- components/rgbd-sources/src/stereovideo.cpp | 7 +++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/common/cpp/include/ftl/configuration.hpp b/components/common/cpp/include/ftl/configuration.hpp index 9010858c4..18ce61f4c 100644 --- a/components/common/cpp/include/ftl/configuration.hpp +++ b/components/common/cpp/include/ftl/configuration.hpp @@ -27,6 +27,8 @@ namespace config { typedef nlohmann::json json_t; +void addPath(const std::string &path); + std::optional<std::string> locateFile(const std::string &name); std::map<std::string, std::string> read_options(char ***argv, int *argc); diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index a10ba86e5..b849c6ff1 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -106,6 +106,11 @@ bool ftl::create_directory(const std::string &path) { #endif } +void ftl::config::addPath(const std::string &path) { + auto &paths = rootCFG->getConfig()["paths"]; + paths.push_back(path); +} + optional<string> ftl::config::locateFile(const string &name) { if (is_file(name)) return name; diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp index b3b9e82b2..06caebb23 100644 --- a/components/rgbd-sources/src/source.cpp +++ b/components/rgbd-sources/src/source.cpp @@ -92,7 +92,7 @@ ftl::rgbd::detail::Source *Source::_createFileImpl(const ftl::URI &uri) { if (eix == string::npos) { // Might be a directory if (ftl::is_directory(path)) { - return new StereoVideoSource(this); + return new StereoVideoSource(this, path); } else { return nullptr; } diff --git a/components/rgbd-sources/src/stereovideo.cpp b/components/rgbd-sources/src/stereovideo.cpp index b75380746..86a9e10b2 100644 --- a/components/rgbd-sources/src/stereovideo.cpp +++ b/components/rgbd-sources/src/stereovideo.cpp @@ -31,12 +31,15 @@ StereoVideoSource::~StereoVideoSource() { } void StereoVideoSource::init(const string &file) { + LOG(INFO) << "STEREOSOURCE = " << file; if (ftl::is_video(file)) { // Load video file LOG(INFO) << "Using video file..."; lsrc_ = ftl::create<LocalSource>(host_, "feed", file); - } - else if (file != "") { + } else if (ftl::is_directory(file)) { + // FIXME: This is not an ideal solution... + ftl::config::addPath(file); + auto vid = ftl::locateFile("video.mp4"); if (!vid) { LOG(FATAL) << "No video.mp4 file found in provided paths (" << file << ")"; -- GitLab