45 std::string file_base;
46 std::vector<unsigned int> file_range;
50 file = params.
get<FileName>(
"file");
56 file_base = params.
get<FileNameNoExtension>(
"file_base");
58 file_range = params.
get<std::vector<unsigned int>>(
"file_range");
65 if (has_file && has_file_base)
72 if (!has_file && !has_file_base)
79 if (has_file_base && !has_file_suffix)
86 if (has_file && has_file_range)
87 mooseWarning(
"Warning: file_range was ignored since a filename was provided.");
90 if (has_file_base && !has_file_range)
92 file_range.push_back(0);
99 if (has_file_range && file_range.size() == 1)
100 file_range.push_back(file_range[0]);
104 if (has_file_range && file_range.size() != 2)
106 mooseWarning(
"A maximum of two values are allowed in the file_range, extra values truncated.");
107 file_range.resize(2);
111 std::sort(file_range.begin(), file_range.end());
117 else if (has_file_base)
124 tinydir_open_sorted(&dir, split_file.first.c_str());
127 std::ostringstream oss;
128 oss <<
"(" << split_file.second <<
".*?(\\d+))\\..*";
129 pcrecpp::RE file_base_and_num_regex(oss.str());
136 tinydir_readfile_n(&dir, &file, i);
141 std::string the_base;
142 unsigned int file_num = 0;
143 file_base_and_num_regex.FullMatch(file.name, &the_base, &file_num);
145 if (!the_base.empty() && file_num >= file_range[0] && file_num <= file_range[1])
146 _filenames.push_back(split_file.first +
"/" + file.name);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
std::pair< std::filesystem::path, std::filesystem::path > splitFileName(const T &full_file)
Function for splitting path and filename.
auto max(const L &left, const R &right)
bool hasExtension(const std::string &filename, std::string ext, bool strip_exodus_ext=false)
Function tests if the supplied filename as the desired extension.
IntRange< T > make_range(T beg, T end)
std::vector< std::string > _filenames