38{
42
43
44 std::string file;
45 std::string file_base;
46 std::vector<unsigned int> file_range;
47
48 if (has_file)
49 {
50 file = params.
get<FileName>(
"file");
51
52
54 }
55 if (has_file_base)
56 file_base = params.
get<FileNameNoExtension>(
"file_base");
57 if (has_file_range)
58 file_range = params.
get<std::vector<unsigned int>>(
"file_range");
59 if (has_file_suffix)
61
62
63
64
65 if (has_file && has_file_base)
66 {
68 return;
69 }
70
71
72 if (!has_file && !has_file_base)
73 {
75 return;
76 }
77
78
79 if (has_file_base && !has_file_suffix)
80 {
82 return;
83 }
84
85
86 if (has_file && has_file_range)
87 mooseWarning(
"Warning: file_range was ignored since a filename was provided.");
88
89
90 if (has_file_base && !has_file_range)
91 {
92 file_range.push_back(0);
93 file_range.push_back(std::numeric_limits<unsigned int>::max());
94 }
95
96
97
98
99 if (has_file_range && file_range.size() == 1)
100 file_range.push_back(file_range[0]);
101
102
103
104 if (has_file_range && file_range.size() != 2)
105 {
106 mooseWarning(
"A maximum of two values are allowed in the file_range, extra values truncated.");
107 file_range.resize(2);
108 }
109
110
111 std::sort(file_range.begin(), file_range.end());
112
113
114 if (has_file)
116
117 else if (has_file_base)
118 {
119
120 std::pair<std::string, std::string> split_file = MooseUtils::splitFileName(file_base);
121
122
123 tinydir_dir dir;
124 tinydir_open_sorted(&dir, split_file.first.c_str());
125
126
127 std::ostringstream oss;
128 oss << "(" << split_file.second << ".*?(\\d+))\\..*";
129 pcrecpp::RE file_base_and_num_regex(oss.str());
130
131
133 {
134
135 tinydir_file file;
136 tinydir_readfile_n(&dir, &file, i);
137
138
140 {
141 std::string the_base;
142 unsigned int file_num = 0;
143 file_base_and_num_regex.FullMatch(file.name, &the_base, &file_num);
144
145 if (!the_base.empty() && file_num >= file_range[0] && file_num <= file_range[1])
146 _filenames.push_back(split_file.first +
"/" + file.name);
147 }
148 }
149 tinydir_close(&dir);
150 }
151
152 else
154
155
156}
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
std::vector< std::string > _filenames
bool hasExtension(const std::string &filename, std::string ext, bool strip_exodus_ext)
IntRange< T > make_range(T beg, T end)