-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileFilter.hpp
46 lines (40 loc) · 1.37 KB
/
fileFilter.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by liyan on 2019/10/27.
//
#ifndef MYMAXSAT_FILEFILTER_HPP
#define MYMAXSAT_FILEFILTER_HPP
#include <io.h>
#include "config.h"
static void instFilter(List<String> &inst_list, String year, String type) {
String filter = Cfg::InstanceFolder + year + '/' + type + "/*.*cnf";
_finddata_t inst_data;
auto handler = _findfirst(filter.c_str(), &inst_data);
if (handler == -1) {
std::cout << filter << " not found!" << std::endl;
return; // [todo] add exception
}
do {
if (strcmp(inst_data.name, ".") == 0 || strcmp(inst_data.name, "..") == 0) { continue; }
inst_list.emplace_back(inst_data.name);
} while (_findnext(handler, &inst_data) == 0);
_findclose(handler);
}
static void typeFilter(HashMap<String, List<String>> &inst_map, String year) {
String filter = Cfg::InstanceFolder + year + "/*.*";
_finddata_t type_data;
auto handler = _findfirst(filter.c_str(), &type_data);
if (handler == -1) {
std::cout << filter << " not found!" << std::endl;
return; // [todo] add exception
}
do {
if (strcmp(type_data.name, ".") == 0 || strcmp(type_data.name, "..") == 0) { continue; }
if (type_data.attrib & _A_SUBDIR) {
List<String> inst_list; inst_list.reserve(40);
instFilter(inst_list, year, type_data.name);
inst_map[type_data.name] = inst_list;
}
} while (_findnext(handler, &type_data) == 0);
_findclose(handler);
}
#endif // MYMAXSAT_FILEFILTER_HPP