Skip to content
Snippets Groups Projects
Commit e8b9e32e authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix for using test data directories

parent c8503891
Branches
Tags
No related merge requests found
...@@ -27,6 +27,8 @@ namespace config { ...@@ -27,6 +27,8 @@ namespace config {
typedef nlohmann::json json_t; typedef nlohmann::json json_t;
void addPath(const std::string &path);
std::optional<std::string> locateFile(const std::string &name); std::optional<std::string> locateFile(const std::string &name);
std::map<std::string, std::string> read_options(char ***argv, int *argc); std::map<std::string, std::string> read_options(char ***argv, int *argc);
......
...@@ -106,6 +106,11 @@ bool ftl::create_directory(const std::string &path) { ...@@ -106,6 +106,11 @@ bool ftl::create_directory(const std::string &path) {
#endif #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) { optional<string> ftl::config::locateFile(const string &name) {
if (is_file(name)) return name; if (is_file(name)) return name;
......
...@@ -92,7 +92,7 @@ ftl::rgbd::detail::Source *Source::_createFileImpl(const ftl::URI &uri) { ...@@ -92,7 +92,7 @@ ftl::rgbd::detail::Source *Source::_createFileImpl(const ftl::URI &uri) {
if (eix == string::npos) { if (eix == string::npos) {
// Might be a directory // Might be a directory
if (ftl::is_directory(path)) { if (ftl::is_directory(path)) {
return new StereoVideoSource(this); return new StereoVideoSource(this, path);
} else { } else {
return nullptr; return nullptr;
} }
......
...@@ -31,12 +31,15 @@ StereoVideoSource::~StereoVideoSource() { ...@@ -31,12 +31,15 @@ StereoVideoSource::~StereoVideoSource() {
} }
void StereoVideoSource::init(const string &file) { void StereoVideoSource::init(const string &file) {
LOG(INFO) << "STEREOSOURCE = " << file;
if (ftl::is_video(file)) { if (ftl::is_video(file)) {
// Load video file // Load video file
LOG(INFO) << "Using video file..."; LOG(INFO) << "Using video file...";
lsrc_ = ftl::create<LocalSource>(host_, "feed", file); lsrc_ = ftl::create<LocalSource>(host_, "feed", file);
} } else if (ftl::is_directory(file)) {
else if (file != "") { // FIXME: This is not an ideal solution...
ftl::config::addPath(file);
auto vid = ftl::locateFile("video.mp4"); auto vid = ftl::locateFile("video.mp4");
if (!vid) { if (!vid) {
LOG(FATAL) << "No video.mp4 file found in provided paths (" << file << ")"; LOG(FATAL) << "No video.mp4 file found in provided paths (" << file << ")";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment