|
@@ -32,10 +32,14 @@
|
|
|
#ifndef config_hpp
|
|
|
#define config_hpp
|
|
|
|
|
|
+#include <cstdlib>
|
|
|
+#include <cstdio>
|
|
|
#include <string>
|
|
|
#include <fstream>
|
|
|
#include <sstream>
|
|
|
|
|
|
+#include <regex>
|
|
|
+
|
|
|
#include "yaml-cpp/yaml.h"
|
|
|
|
|
|
namespace fv_util {
|
|
@@ -87,6 +91,22 @@ namespace YAML {
|
|
|
|
|
|
namespace fv_util {
|
|
|
|
|
|
+
|
|
|
+ std::vector<std::string> glob(const std::string& base) {
|
|
|
+ std::stringstream ss;
|
|
|
+ ss << "ls -1 " << base << " > __tmp__";
|
|
|
+ system(ss.str().c_str());
|
|
|
+
|
|
|
+ std::vector<std::string> filenames;
|
|
|
+ std::ifstream f("__tmp__");
|
|
|
+ std::string line;
|
|
|
+ while (std::getline(f, line)) {
|
|
|
+ filenames.push_back(line);
|
|
|
+ }
|
|
|
+ std::remove("__tmp__");
|
|
|
+ return filenames;
|
|
|
+ }
|
|
|
+
|
|
|
class Config {
|
|
|
private:
|
|
|
std::string input_filename;
|
|
@@ -155,7 +175,14 @@ namespace fv_util {
|
|
|
source_file_key = root["source-file-key"].as<std::string>();
|
|
|
}
|
|
|
YAML::Node source_files_nd = root[source_file_key];
|
|
|
- if (source_files_nd.IsSequence()) {
|
|
|
+ if (source_files_nd.IsMap()) {
|
|
|
+ auto filenames = glob(source_files_nd["files"].as<std::string>());
|
|
|
+ DataFileDescriptor dfd;
|
|
|
+ for (const auto& filename : filenames) {
|
|
|
+ dfd.filename = filename;
|
|
|
+ source_files.push_back(dfd);
|
|
|
+ }
|
|
|
+ } else if (source_files_nd.IsSequence()) {
|
|
|
for (const auto &f : source_files_nd) {
|
|
|
source_files.push_back(f.as<DataFileDescriptor>());
|
|
|
}
|